2
0

PgsqlTest.php 3.4 KB

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