SqliteTest.php 5.2 KB

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