PgsqlTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /**
  23. * @see Zend_Db_Select_TestCommon
  24. */
  25. require_once 'Zend/Db/Select/TestCommon.php';
  26. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  27. /**
  28. * @category Zend
  29. * @package Zend_Db
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Db_Select_Pdo_PgsqlTest extends Zend_Db_Select_TestCommon
  35. {
  36. public function getDriver()
  37. {
  38. return 'Pdo_Pgsql';
  39. }
  40. /**
  41. * This test must be done on string field
  42. */
  43. protected function _selectColumnWithColonQuotedParameter ()
  44. {
  45. $product_name = $this->_db->quoteIdentifier('product_name');
  46. $select = $this->_db->select()
  47. ->from('zfproducts')
  48. ->where($product_name . ' = ?', "as'as:x");
  49. return $select;
  50. }
  51. public function testSelectGroupByExpr()
  52. {
  53. $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
  54. }
  55. public function testSelectGroupByAutoExpr()
  56. {
  57. $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
  58. }
  59. /**
  60. * Ensures that from() provides expected behavior using schema specification
  61. *
  62. * @return void
  63. */
  64. public function testSelectFromSchemaSpecified()
  65. {
  66. $schema = 'public';
  67. $table = 'zfbugs';
  68. $sql = $this->_db->select()->from($table, '*', $schema);
  69. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  70. $rowset = $this->_db->fetchAll($sql);
  71. $this->assertEquals(4, count($rowset));
  72. }
  73. /**
  74. * Ensures that from() provides expected behavior using schema in the table name
  75. *
  76. * @return void
  77. */
  78. public function testSelectFromSchemaInName()
  79. {
  80. $schema = 'public';
  81. $table = 'zfbugs';
  82. $name = "$schema.$table";
  83. $sql = $this->_db->select()->from($name);
  84. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  85. $rowset = $this->_db->fetchAll($sql);
  86. $this->assertEquals(4, count($rowset));
  87. }
  88. /**
  89. * Ensures that from() overrides schema specification with schema in the table name
  90. *
  91. * @return void
  92. */
  93. public function testSelectFromSchemaInNameOverridesSchemaArgument()
  94. {
  95. $schema = 'public';
  96. $table = 'zfbugs';
  97. $name = "$schema.$table";
  98. $sql = $this->_db->select()->from($name, '*', 'ignored');
  99. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  100. $rowset = $this->_db->fetchAll($sql);
  101. $this->assertEquals(4, count($rowset));
  102. }
  103. }