IbmTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. require_once 'Zend/Db/Statement/Pdo/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Db
  30. * @group Zend_Db_Statement
  31. */
  32. class Zend_Db_Statement_Pdo_IbmTest extends Zend_Db_Statement_Pdo_TestCommon
  33. {
  34. public function getDriver()
  35. {
  36. return 'Pdo_Ibm';
  37. }
  38. /**
  39. * used by testStatementGetColumnMeta()
  40. *
  41. */
  42. protected $_getColumnMetaKeys = array(
  43. 'scale', 'table', 'native_type', 'flags', 'name', 'len', 'precision', 'pdo_type'
  44. );
  45. public function testStatementNextRowset()
  46. {
  47. $select = $this->_db->select()
  48. ->from('zfproducts');
  49. $stmt = $this->_db->prepare($select->__toString());
  50. $result = $stmt->nextRowset();
  51. // there is no next rowset so $result should be false
  52. $this->assertFalse($result);
  53. $stmt->closeCursor();
  54. }
  55. public function testStatementColumnCountForSelect()
  56. {
  57. $select = $this->_db->select()
  58. ->from('zfproducts');
  59. $stmt = $this->_db->prepare($select->__toString());
  60. $n = $stmt->columnCount();
  61. $this->assertEquals(2, $n);
  62. $stmt->execute();
  63. $n = $stmt->columnCount();
  64. $stmt->closeCursor();
  65. $this->assertTrue(is_int($n));
  66. $this->assertEquals(2, $n);
  67. }
  68. public function testStatementGetSetAttribute()
  69. {
  70. $select = $this->_db->select()
  71. ->from('zfproducts');
  72. $stmt = $this->_db->prepare($select->__toString());
  73. $value = 'value';
  74. try {
  75. $stmt->setAttribute(1234, $value);
  76. } catch (Zend_Exception $e) {
  77. $this->assertContains('This driver doesn\'t support setting attributes', $e->getMessage());
  78. }
  79. try {
  80. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1");
  81. } catch (Zend_Exception $e) {
  82. $this->assertContains('Driver does not support this function: 1 Unknown attribute', $e->getMessage());
  83. return;
  84. }
  85. $valueArray = array('value1', 'value2');
  86. $stmt->setAttribute(1235, $valueArray);
  87. $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #1");
  88. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
  89. $valueObject = new stdClass();
  90. $stmt->setAttribute(1236, $valueObject);
  91. $this->assertSame($valueObject, $stmt->getAttribute(1236), "Expected object");
  92. $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #2");
  93. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
  94. }
  95. }