mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Merge pull request #12680 from bancer/issue-12636-tests-constants
Replace hard coded test directory paths with constants, fixes #12636
This commit is contained in:
commit
89005c4440
4 changed files with 27 additions and 20 deletions
|
@ -360,23 +360,19 @@ class TestShell extends Shell {
|
|||
}
|
||||
|
||||
$testFile = $testCase = null;
|
||||
|
||||
$testCaseFolder = str_replace(APP, '', APP_TEST_CASES);
|
||||
if (preg_match('@Test[\\\/]@', $file)) {
|
||||
|
||||
if (substr($file, -8) === 'Test.php') {
|
||||
|
||||
$testCase = substr($file, 0, -8);
|
||||
$testCase = str_replace(DS, '/', $testCase);
|
||||
|
||||
if ($testCase = preg_replace('@.*Test\/Case\/@', '', $testCase)) {
|
||||
|
||||
$testCaseFolderEscaped = str_replace('/', '\/', $testCaseFolder);
|
||||
$testCase = preg_replace('@.*' . $testCaseFolderEscaped . '\/@', '', $testCase);
|
||||
if (!empty($testCase)) {
|
||||
if ($category === 'core') {
|
||||
$testCase = str_replace('lib/Cake', '', $testCase);
|
||||
}
|
||||
|
||||
return $testCase;
|
||||
}
|
||||
|
||||
throw new Exception(__d('cake_dev', 'Test case %s cannot be run via this shell', $testFile));
|
||||
}
|
||||
}
|
||||
|
@ -397,11 +393,11 @@ class TestShell extends Shell {
|
|||
}
|
||||
|
||||
if ($category === 'app') {
|
||||
$testFile = str_replace(APP, APP . 'Test/Case/', $file) . 'Test.php';
|
||||
$testFile = str_replace(APP, APP_TEST_CASES . '/', $file) . 'Test.php';
|
||||
} else {
|
||||
$testFile = preg_replace(
|
||||
"@((?:plugins|Plugin)[\\/]{$category}[\\/])(.*)$@",
|
||||
'\1Test/Case/\2Test.php',
|
||||
'\1' . $testCaseFolder . '/\2Test.php',
|
||||
$file
|
||||
);
|
||||
}
|
||||
|
@ -412,8 +408,7 @@ class TestShell extends Shell {
|
|||
|
||||
$testCase = substr($testFile, 0, -8);
|
||||
$testCase = str_replace(DS, '/', $testCase);
|
||||
$testCase = preg_replace('@.*Test/Case/@', '', $testCase);
|
||||
|
||||
$testCase = preg_replace('@.*' . $testCaseFolder . '/@', '', $testCase);
|
||||
return $testCase;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@ class Configure {
|
|||
class_exists('Debugger');
|
||||
class_exists('CakeText');
|
||||
}
|
||||
if (!defined('TESTS')) {
|
||||
define('TESTS', APP . 'Test' . DS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,24 @@
|
|||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Path to the tests directory of the app.
|
||||
*/
|
||||
if (!defined('TESTS')) {
|
||||
define('TESTS', APP . 'Test' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the test cases directory of CakePHP.
|
||||
*/
|
||||
define('CORE_TEST_CASES', CAKE . 'Test' . DS . 'Case');
|
||||
define('APP_TEST_CASES', TESTS . 'Case');
|
||||
|
||||
/**
|
||||
* Path to the test cases directory of the app.
|
||||
*/
|
||||
if (!defined('APP_TEST_CASES')) {
|
||||
define('APP_TEST_CASES', TESTS . 'Case');
|
||||
}
|
||||
|
||||
App::uses('CakeTestSuiteCommand', 'TestSuite');
|
||||
|
||||
|
|
|
@ -86,13 +86,6 @@ if (!defined('IMAGES')) {
|
|||
define('IMAGES', WWW_ROOT . 'img' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the tests directory.
|
||||
*/
|
||||
if (!defined('TESTS')) {
|
||||
define('TESTS', APP . 'Test' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the temporary files directory.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue