SqliteTest.php 6.5 KB

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