DatabaseSuite.php 2.1 KB

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