2
0

SqliteTest.php 5.5 KB

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