IbmTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-2009 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. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  24. /**
  25. * @category Zend
  26. * @package Zend_Db
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Db
  31. * @group Zend_Db_Statement
  32. */
  33. class Zend_Db_Statement_Pdo_IbmTest extends Zend_Db_Statement_Pdo_TestCommon
  34. {
  35. public function getDriver()
  36. {
  37. return 'Pdo_Ibm';
  38. }
  39. /**
  40. * used by testStatementGetColumnMeta()
  41. *
  42. */
  43. protected $_getColumnMetaKeys = array(
  44. 'scale', 'table', 'native_type', 'flags', 'name', 'len', 'precision', 'pdo_type'
  45. );
  46. public function testStatementNextRowset()
  47. {
  48. $select = $this->_db->select()
  49. ->from('zfproducts');
  50. $stmt = $this->_db->prepare($select->__toString());
  51. $result = $stmt->nextRowset();
  52. // there is no next rowset so $result should be false
  53. $this->assertFalse($result);
  54. $stmt->closeCursor();
  55. }
  56. public function testStatementColumnCountForSelect()
  57. {
  58. $select = $this->_db->select()
  59. ->from('zfproducts');
  60. $stmt = $this->_db->prepare($select->__toString());
  61. $n = $stmt->columnCount();
  62. $this->assertEquals(2, $n);
  63. $stmt->execute();
  64. $n = $stmt->columnCount();
  65. $stmt->closeCursor();
  66. $this->assertType('integer', $n);
  67. $this->assertEquals(2, $n);
  68. }
  69. public function testStatementGetSetAttribute()
  70. {
  71. $select = $this->_db->select()
  72. ->from('zfproducts');
  73. $stmt = $this->_db->prepare($select->__toString());
  74. $value = 'value';
  75. try {
  76. $stmt->setAttribute(1234, $value);
  77. } catch (Zend_Exception $e) {
  78. $this->assertContains('This driver doesn\'t support setting attributes', $e->getMessage());
  79. }
  80. try {
  81. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1");
  82. } catch (Zend_Exception $e) {
  83. $this->assertContains('Driver does not support this function: 1 Unknown attribute', $e->getMessage());
  84. return;
  85. }
  86. $valueArray = array('value1', 'value2');
  87. $stmt->setAttribute(1235, $valueArray);
  88. $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #1");
  89. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
  90. $valueObject = new stdClass();
  91. $stmt->setAttribute(1236, $valueObject);
  92. $this->assertSame($valueObject, $stmt->getAttribute(1236), "Expected object");
  93. $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #2");
  94. $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
  95. }
  96. }