DatabaseSuite.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * PHP Version 5.4
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @since CakePHP(tm) v 3.0.0
  15. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  16. */
  17. namespace Cake\Test\TestCase;
  18. use Cake\Datasource\ConnectionManager;
  19. use Cake\TestSuite\TestPermutationDecorator;
  20. use Cake\TestSuite\TestSuite;
  21. /**
  22. * All tests related to database
  23. *
  24. */
  25. class DatabaseSuite extends TestSuite {
  26. /**
  27. * Returns a suite containing all tests requiring a database connection,
  28. * tests are decorated so that they are run once with automatic
  29. *
  30. * @return void
  31. */
  32. public static function suite() {
  33. $suite = new self('Database related tests');
  34. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Database');
  35. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'ORM');
  36. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Model');
  37. return $suite;
  38. }
  39. /**
  40. * Returns an iterator for this test suite.
  41. *
  42. * @return ArrayIterator
  43. */
  44. public function getIterator() {
  45. $permutations = [
  46. 'Identifier Quoting' => function() {
  47. ConnectionManager::get('test')->driver()->autoQuoting(true);
  48. },
  49. 'No identifier quoting' => function() {
  50. ConnectionManager::get('test')->driver()->autoQuoting(false);
  51. }
  52. ];
  53. $tests = [];
  54. foreach (parent::getIterator() as $test) {
  55. $tests[] = new TestPermutationDecorator($test, $permutations);
  56. }
  57. return new \ArrayIterator($tests);
  58. }
  59. }