PgsqlTest.php 3.5 KB

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