2
0

PgsqlTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. * @group Zend_Db
  34. * @group Zend_Db_Select
  35. */
  36. class Zend_Db_Select_Pdo_PgsqlTest extends Zend_Db_Select_TestCommon
  37. {
  38. public function getDriver()
  39. {
  40. return 'Pdo_Pgsql';
  41. }
  42. /**
  43. * This test must be done on string field
  44. */
  45. protected function _selectColumnWithColonQuotedParameter ()
  46. {
  47. $product_name = $this->_db->quoteIdentifier('product_name');
  48. $select = $this->_db->select()
  49. ->from('zfproducts')
  50. ->where($product_name . ' = ?', "as'as:x");
  51. return $select;
  52. }
  53. public function testSelectGroupByExpr()
  54. {
  55. $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
  56. }
  57. public function testSelectGroupByAutoExpr()
  58. {
  59. $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
  60. }
  61. /**
  62. * Ensures that from() provides expected behavior using schema specification
  63. *
  64. * @return void
  65. */
  66. public function testSelectFromSchemaSpecified()
  67. {
  68. $schema = 'public';
  69. $table = 'zfbugs';
  70. $sql = $this->_db->select()->from($table, '*', $schema);
  71. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  72. $rowset = $this->_db->fetchAll($sql);
  73. $this->assertEquals(4, count($rowset));
  74. }
  75. /**
  76. * Ensures that from() provides expected behavior using schema in the table name
  77. *
  78. * @return void
  79. */
  80. public function testSelectFromSchemaInName()
  81. {
  82. $schema = 'public';
  83. $table = 'zfbugs';
  84. $name = "$schema.$table";
  85. $sql = $this->_db->select()->from($name);
  86. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  87. $rowset = $this->_db->fetchAll($sql);
  88. $this->assertEquals(4, count($rowset));
  89. }
  90. /**
  91. * Ensures that from() overrides schema specification with schema in the table name
  92. *
  93. * @return void
  94. */
  95. public function testSelectFromSchemaInNameOverridesSchemaArgument()
  96. {
  97. $schema = 'public';
  98. $table = 'zfbugs';
  99. $name = "$schema.$table";
  100. $sql = $this->_db->select()->from($name, '*', 'ignored');
  101. $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
  102. $rowset = $this->_db->fetchAll($sql);
  103. $this->assertEquals(4, count($rowset));
  104. }
  105. }