mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
simplify path logic
we know the category - use it to simplify some regexs
This commit is contained in:
parent
dcf14a7a44
commit
8b1045a631
1 changed files with 14 additions and 5 deletions
|
@ -337,6 +337,11 @@ class TestShell extends Shell {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_file = realpath($file);
|
||||||
|
if ($_file) {
|
||||||
|
$file = $_file;
|
||||||
|
}
|
||||||
|
|
||||||
$testFile = $testCase = null;
|
$testFile = $testCase = null;
|
||||||
|
|
||||||
if (preg_match('@Test[\\\/]@', $file)) {
|
if (preg_match('@Test[\\\/]@', $file)) {
|
||||||
|
@ -376,11 +381,15 @@ class TestShell extends Shell {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($category === 'app') {
|
||||||
|
$testFile = str_replace(APP, APP . 'Test/Case/', $file) . 'Test.php';
|
||||||
|
} else {
|
||||||
$testFile = preg_replace(
|
$testFile = preg_replace(
|
||||||
'@(.*)((?:(?:Config|Console|Controller|Lib|Locale|Model|plugins|Plugin|Test|Vendor|View|webroot)[\\\/]).*$|App[-a-z]*$)@',
|
"@((?:plugins|Plugin)[\\/]{$category}[\\/])(.*)$@",
|
||||||
'\1Test/Case/\2Test.php',
|
'\1Test/Case/\2Test.php',
|
||||||
$file
|
$file
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_exists($testFile)) {
|
if (!file_exists($testFile)) {
|
||||||
throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile));
|
throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile));
|
||||||
|
|
Loading…
Add table
Reference in a new issue