DatabaseSuite.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 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. use \PHPUnit_Framework_TestResult;
  22. /**
  23. * All tests related to database
  24. *
  25. */
  26. class DatabaseSuite extends TestSuite {
  27. /**
  28. * Returns a suite containing all tests requiring a database connection,
  29. * tests are decorated so that they are run once with automatic
  30. *
  31. * @return void
  32. */
  33. public static function suite() {
  34. $suite = new self('Database related tests');
  35. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Database');
  36. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'ORM');
  37. $suite->addTestDirectoryRecursive(__DIR__ . DS . 'Model');
  38. return $suite;
  39. }
  40. public function count() {
  41. return parent::count() * 2;
  42. }
  43. /**
  44. * Runs the tests and collects their result in a TestResult.
  45. *
  46. * @param \PHPUnit_Framework_TestResult $result
  47. * @return \PHPUnit_Framework_TestResult
  48. */
  49. public function run(PHPUnit_Framework_TestResult $result = null, $filter = false, array $groups = [], array $excludeGroups = [], $processIsolation = false) {
  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, $filter, $groups, $excludeGroups, $processIsolation);
  61. }
  62. return $result;
  63. }
  64. }