From 8b1045a631cf146d7800fba26cdbbe97e15816c9 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sun, 29 May 2011 01:49:21 +0200 Subject: [PATCH] simplify path logic we know the category - use it to simplify some regexs --- lib/Cake/Console/Command/TestShell.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Console/Command/TestShell.php b/lib/Cake/Console/Command/TestShell.php index 096d2fc11..b461ce960 100644 --- a/lib/Cake/Console/Command/TestShell.php +++ b/lib/Cake/Console/Command/TestShell.php @@ -337,6 +337,11 @@ class TestShell extends Shell { return false; } + $_file = realpath($file); + if ($_file) { + $file = $_file; + } + $testFile = $testCase = null; if (preg_match('@Test[\\\/]@', $file)) { @@ -376,11 +381,15 @@ class TestShell extends Shell { return false; } - $testFile = preg_replace( - '@(.*)((?:(?:Config|Console|Controller|Lib|Locale|Model|plugins|Plugin|Test|Vendor|View|webroot)[\\\/]).*$|App[-a-z]*$)@', - '\1Test/Case/\2Test.php', - $file - ); + if ($category === 'app') { + $testFile = str_replace(APP, APP . 'Test/Case/', $file) . 'Test.php'; + } else { + $testFile = preg_replace( + "@((?:plugins|Plugin)[\\/]{$category}[\\/])(.*)$@", + '\1Test/Case/\2Test.php', + $file + ); + } if (!file_exists($testFile)) { throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile));