DatabaseSuite.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * Returns a suite containing all tests requiring a database connection,
  27. * tests are decorated so that they are run once with automatic
  28. *
  29. * @return void
  30. */
  31. public static function suite() {
  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. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Model');
  37. return $suite;
  38. }
  39. public function count() {
  40. return parent::count() * 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(PHPUnit_Framework_TestResult $result = null, $filter = false, array $groups = [], array $excludeGroups = [], $processIsolation = false) {
  49. $permutations = [
  50. 'Identifier Quoting' => function() {
  51. ConnectionManager::get('test')->driver()->autoQuoting(true);
  52. },
  53. 'No identifier quoting' => function() {
  54. ConnectionManager::get('test')->driver()->autoQuoting(false);
  55. }
  56. ];
  57. foreach ($permutations as $permutation) {
  58. $permutation();
  59. $result = parent::run($result, $filter, $groups, $excludeGroups, $processIsolation);
  60. }
  61. return $result;
  62. }
  63. }