SqliteTest.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. require_once 'Zend/Db/Table/Select/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Db
  30. * @group Zend_Db_Table
  31. * @group Zend_Db_Table_Select
  32. */
  33. class Zend_Db_Table_Select_Pdo_SqliteTest extends Zend_Db_Table_Select_TestCommon
  34. {
  35. public function testSelectFromQualified()
  36. {
  37. $this->markTestSkipped($this->getDriver() . ' does not support qualified table names');
  38. }
  39. public function testSelectJoinQualified()
  40. {
  41. $this->markTestSkipped($this->getDriver() . ' does not support qualified table names');
  42. }
  43. public function testSelectFromForUpdate()
  44. {
  45. $this->markTestSkipped($this->getDriver() . ' does not support FOR UPDATE');
  46. }
  47. public function testSelectJoinRight()
  48. {
  49. $this->markTestSkipped($this->getDriver() . ' does not support RIGHT OUTER JOIN');
  50. }
  51. public function testSelectGroupBy()
  52. {
  53. //SQLite doesn't need different test from 5.3
  54. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  55. return parent::testSelectGroupBy();
  56. }
  57. $select = $this->_selectGroupBy();
  58. $stmt = $this->_db->query($select);
  59. $result = $stmt->fetchAll();
  60. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  61. $bug_id = $this->_db->quoteIdentifier('bug_id');
  62. $key = "$bugs_products.$bug_id";
  63. $this->assertEquals(3, count($result),
  64. 'Expected count of first result set to be 2');
  65. $this->assertEquals(1, $result[0][$key]);
  66. $this->assertEquals(3, $result[0]['thecount'],
  67. 'Expected count(*) of first result set to be 2');
  68. $this->assertEquals(2, $result[1][$key]);
  69. $this->assertEquals(1, $result[1]['thecount']);
  70. }
  71. public function testSelectGroupByQualified()
  72. {
  73. //SQLite doesn't need different test from 5.3
  74. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  75. return parent::testSelectGroupByQualified();
  76. }
  77. $select = $this->_selectGroupByQualified();
  78. $stmt = $this->_db->query($select);
  79. $result = $stmt->fetchAll();
  80. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  81. $bug_id = $this->_db->quoteIdentifier('bug_id');
  82. $key = "$bugs_products.$bug_id";
  83. $this->assertEquals(3, count($result),
  84. 'Expected count of first result set to be 2');
  85. $this->assertEquals(1, $result[0][$key]);
  86. $this->assertEquals(3, $result[0]['thecount'],
  87. 'Expected count(*) of first result set to be 2');
  88. $this->assertEquals(2, $result[1][$key]);
  89. $this->assertEquals(1, $result[1]['thecount']);
  90. }
  91. public function testSelectHaving()
  92. {
  93. //SQLite doesn't need different test from 5.3
  94. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  95. return parent::testSelectHaving();
  96. }
  97. $select = $this->_selectHaving();
  98. $stmt = $this->_db->query($select);
  99. $result = $stmt->fetchAll();
  100. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  101. $bug_id = $this->_db->quoteIdentifier('bug_id');
  102. $key = "$bugs_products.$bug_id";
  103. $this->assertEquals(2, count($result));
  104. $this->assertEquals(1, $result[0][$key]);
  105. $this->assertEquals(3, $result[0]['thecount']);
  106. }
  107. public function testSelectHavingWithParameter()
  108. {
  109. //SQLite doesn't need different test from 5.3
  110. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  111. return parent::testSelectHavingWithParameter();
  112. }
  113. $select = $this->_selectHavingWithParameter();
  114. $stmt = $this->_db->query($select);
  115. $result = $stmt->fetchAll();
  116. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  117. $bug_id = $this->_db->quoteIdentifier('bug_id');
  118. $key = "$bugs_products.$bug_id";
  119. $this->assertEquals(2, count($result));
  120. $this->assertEquals(1, $result[0][$key]);
  121. $this->assertEquals(3, $result[0]['thecount']);
  122. }
  123. public function testSelectHavingOr()
  124. {
  125. //SQLite doesn't need different test from 5.3
  126. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  127. return parent::testSelectHavingOr();
  128. }
  129. $select = $this->_selectHavingOr();
  130. $stmt = $this->_db->query($select);
  131. $result = $stmt->fetchAll();
  132. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  133. $bug_id = $this->_db->quoteIdentifier('bug_id');
  134. $key = "$bugs_products.$bug_id";
  135. $this->assertEquals(3, count($result));
  136. $this->assertEquals(1, $result[0][$key]);
  137. $this->assertEquals(3, $result[0]['thecount']);
  138. $this->assertEquals(2, $result[1][$key]);
  139. $this->assertEquals(1, $result[1]['thecount']);
  140. }
  141. public function testSelectHavingOrWithParameter()
  142. {
  143. //SQLite doesn't need different test from 5.3
  144. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  145. return parent::testSelectHavingOrWithParameter();
  146. }
  147. $select = $this->_selectHavingOrWithParameter();
  148. $stmt = $this->_db->query($select);
  149. $result = $stmt->fetchAll();
  150. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  151. $bug_id = $this->_db->quoteIdentifier('bug_id');
  152. $key = "$bugs_products.$bug_id";
  153. $this->assertEquals(3, count($result));
  154. $this->assertEquals(1, $result[0][$key]);
  155. $this->assertEquals(3, $result[0]['thecount']);
  156. $this->assertEquals(2, $result[1][$key]);
  157. $this->assertEquals(1, $result[1]['thecount']);
  158. }
  159. public function getDriver()
  160. {
  161. return 'Pdo_Sqlite';
  162. }
  163. }