DatabaseSuite.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase;
  16. use Cake\Datasource\ConnectionManager;
  17. use Cake\TestSuite\TestPermutationDecorator;
  18. use Cake\TestSuite\TestSuite;
  19. use \PHPUnit_Framework_TestResult;
  20. /**
  21. * All tests related to database
  22. *
  23. */
  24. class DatabaseSuite extends TestSuite
  25. {
  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. {
  34. $suite = new self('Database related tests');
  35. $suite->addTestFile(__DIR__ . DS . 'Database' . DS . 'ConnectionTest.php');
  36. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Database');
  37. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'ORM');
  38. return $suite;
  39. }
  40. public function count()
  41. {
  42. return parent::count() * 2;
  43. }
  44. /**
  45. * Runs the tests and collects their result in a TestResult.
  46. *
  47. * @param \PHPUnit_Framework_TestResult $result
  48. * @return \PHPUnit_Framework_TestResult
  49. */
  50. public function run(PHPUnit_Framework_TestResult $result = null)
  51. {
  52. $permutations = [
  53. 'Identifier Quoting' => function () {
  54. ConnectionManager::get('test')->driver()->autoQuoting(true);
  55. },
  56. 'No identifier quoting' => function () {
  57. ConnectionManager::get('test')->driver()->autoQuoting(false);
  58. }
  59. ];
  60. foreach ($permutations as $permutation) {
  61. $permutation();
  62. $result = parent::run($result);
  63. }
  64. return $result;
  65. }
  66. }