SqliteTest.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. require_once 'Zend/Db/Select/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2012 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. $select = $this->_selectGroupBy();
  53. $stmt = $this->_db->query($select);
  54. $result = $stmt->fetchAll();
  55. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  56. $bug_id = $this->_db->quoteIdentifier('bug_id');
  57. $key = "$bugs_products.$bug_id";
  58. $this->assertEquals(3, count($result),
  59. 'Expected count of first result set to be 2');
  60. $this->assertEquals(1, $result[0][$key]);
  61. $this->assertEquals(3, $result[0]['thecount'],
  62. 'Expected count(*) of first result set to be 2');
  63. $this->assertEquals(2, $result[1][$key]);
  64. $this->assertEquals(1, $result[1]['thecount']);
  65. }
  66. public function testSelectGroupByQualified()
  67. {
  68. $select = $this->_selectGroupByQualified();
  69. $stmt = $this->_db->query($select);
  70. $result = $stmt->fetchAll();
  71. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  72. $bug_id = $this->_db->quoteIdentifier('bug_id');
  73. $key = "$bugs_products.$bug_id";
  74. $this->assertEquals(3, count($result),
  75. 'Expected count of first result set to be 2');
  76. $this->assertEquals(1, $result[0][$key]);
  77. $this->assertEquals(3, $result[0]['thecount'],
  78. 'Expected count(*) of first result set to be 2');
  79. $this->assertEquals(2, $result[1][$key]);
  80. $this->assertEquals(1, $result[1]['thecount']);
  81. }
  82. public function testSelectHaving()
  83. {
  84. $select = $this->_selectHaving();
  85. $stmt = $this->_db->query($select);
  86. $result = $stmt->fetchAll();
  87. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  88. $bug_id = $this->_db->quoteIdentifier('bug_id');
  89. $key = "$bugs_products.$bug_id";
  90. $this->assertEquals(2, count($result));
  91. $this->assertEquals(1, $result[0][$key]);
  92. $this->assertEquals(3, $result[0]['thecount']);
  93. }
  94. public function testSelectHavingWithParameter()
  95. {
  96. $select = $this->_selectHavingWithParameter();
  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 testSelectHavingOr()
  107. {
  108. $select = $this->_selectHavingOr();
  109. $stmt = $this->_db->query($select);
  110. $result = $stmt->fetchAll();
  111. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  112. $bug_id = $this->_db->quoteIdentifier('bug_id');
  113. $key = "$bugs_products.$bug_id";
  114. $this->assertEquals(3, count($result));
  115. $this->assertEquals(1, $result[0][$key]);
  116. $this->assertEquals(3, $result[0]['thecount']);
  117. $this->assertEquals(2, $result[1][$key]);
  118. $this->assertEquals(1, $result[1]['thecount']);
  119. }
  120. public function testSelectHavingOrWithParameter()
  121. {
  122. $select = $this->_selectHavingOrWithParameter();
  123. $stmt = $this->_db->query($select);
  124. $result = $stmt->fetchAll();
  125. $bugs_products = $this->_db->quoteIdentifier('zfbugs_products');
  126. $bug_id = $this->_db->quoteIdentifier('bug_id');
  127. $key = "$bugs_products.$bug_id";
  128. $this->assertEquals(3, count($result));
  129. $this->assertEquals(1, $result[0][$key]);
  130. $this->assertEquals(3, $result[0]['thecount']);
  131. $this->assertEquals(2, $result[1][$key]);
  132. $this->assertEquals(1, $result[1]['thecount']);
  133. }
  134. public function getDriver()
  135. {
  136. return 'Pdo_Sqlite';
  137. }
  138. }