From 2c3132fa855dc1b69a321902fb5d4da01abcbabf Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 8 May 2011 23:25:32 -0430 Subject: [PATCH] Fixing some TestSuite tests --- lib/Cake/Routing/Dispatcher.php | 14 ++++++++------ lib/Cake/TestSuite/templates/menu.php | 6 ++---- lib/Cake/tests/Case/Core/CakePluginTest.php | 1 + .../Case/TestSuite/ControllerTestCaseTest.php | 7 +++++-- .../Case/TestSuite/HtmlCoverageReportTest.php | 9 +++++++-- lib/Cake/tests/Case/Utility/ClassRegistryTest.php | 1 + 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index a5d0c10a5..53f24a765 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -313,12 +313,14 @@ class Dispatcher { $assetFile = $path . $fileFragment; } } else { - $plugin = $parts[0]; - unset($parts[0]); - $fileFragment = implode(DS, $parts); - $pluginWebroot = App::pluginPath($plugin) . 'webroot' . DS; - if (file_exists($pluginWebroot . $fileFragment)) { - $assetFile = $pluginWebroot . $fileFragment; + $plugin = Inflector::camelize($parts[0]); + if (CakePlugin::loaded($plugin)) { + unset($parts[0]); + $fileFragment = implode(DS, $parts); + $pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS; + if (file_exists($pluginWebroot . $fileFragment)) { + $assetFile = $pluginWebroot . $fileFragment; + } } } diff --git a/lib/Cake/TestSuite/templates/menu.php b/lib/Cake/TestSuite/templates/menu.php index bb81dc7cf..4577908f3 100644 --- a/lib/Cake/TestSuite/templates/menu.php +++ b/lib/Cake/TestSuite/templates/menu.php @@ -30,14 +30,12 @@ if (!empty($plugins)): ?>
  • Plugins - + diff --git a/lib/Cake/tests/Case/Core/CakePluginTest.php b/lib/Cake/tests/Case/Core/CakePluginTest.php index 26c88fb9a..5ef5a4602 100644 --- a/lib/Cake/tests/Case/Core/CakePluginTest.php +++ b/lib/Cake/tests/Case/Core/CakePluginTest.php @@ -27,6 +27,7 @@ class CakePluginTest extends CakeTestCase { */ public function tearDown() { App::build(); + CakePlugin::unload(); Configure::delete('CakePluginTest'); } diff --git a/lib/Cake/tests/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/tests/Case/TestSuite/ControllerTestCaseTest.php index 1bf23d8d3..54f6893b6 100644 --- a/lib/Cake/tests/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/tests/Case/TestSuite/ControllerTestCaseTest.php @@ -127,6 +127,7 @@ class ControllerTestCaseTest extends CakeTestCase { 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS), 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS) )); + CakePlugin::loadAll(); $this->Case = new ControllerTestCase(); Router::reload(); } @@ -138,6 +139,7 @@ class ControllerTestCaseTest extends CakeTestCase { */ function tearDown() { parent::tearDown(); + CakePlugin::unload(); $this->Case->controller = null; } @@ -412,8 +414,9 @@ class ControllerTestCaseTest extends CakeTestCase { 'blue' => 'mana' ) )); - $this->assertTrue(isset($result['params']['url']['red'])); - $this->assertTrue(isset($result['params']['url']['blue'])); + $query = $this->Case->controller->request->query; + $this->assertTrue(isset($query['red'])); + $this->assertTrue(isset($query['blue'])); } /** diff --git a/lib/Cake/tests/Case/TestSuite/HtmlCoverageReportTest.php b/lib/Cake/tests/Case/TestSuite/HtmlCoverageReportTest.php index a8d6ae7db..9a7f61462 100644 --- a/lib/Cake/tests/Case/TestSuite/HtmlCoverageReportTest.php +++ b/lib/Cake/tests/Case/TestSuite/HtmlCoverageReportTest.php @@ -26,6 +26,10 @@ class HtmlCoverageReportTest extends CakeTestCase { * @return void */ public function setUp() { + App::build(array( + 'plugins' => array(CAKE . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) + )); + CakePlugin::loadAll(); $reporter = new CakeBaseReporter(); $reporter->params = array('app' => false, 'plugin' => false, 'group' => false); $coverage = array(); @@ -47,9 +51,9 @@ class HtmlCoverageReportTest extends CakeTestCase { $this->assertEquals(ROOT . DS . APP_DIR . DS, $result); $this->Coverage->appTest = false; - $this->Coverage->pluginTest = 'test_plugin'; + $this->Coverage->pluginTest = 'TestPlugin'; $result = $this->Coverage->getPathFilter(); - $this->assertEquals(ROOT . DS . APP_DIR . DS . 'plugins' . DS .'test_plugin' . DS, $result); + $this->assertEquals(CakePlugin::path('TestPlugin'), $result); } /** @@ -170,6 +174,7 @@ class HtmlCoverageReportTest extends CakeTestCase { * @return void */ function tearDown() { + CakePlugin::unload(); unset($this->Coverage); } } \ No newline at end of file diff --git a/lib/Cake/tests/Case/Utility/ClassRegistryTest.php b/lib/Cake/tests/Case/Utility/ClassRegistryTest.php index 36ba686c6..374427ab6 100644 --- a/lib/Cake/tests/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/tests/Case/Utility/ClassRegistryTest.php @@ -278,5 +278,6 @@ class ClassRegistryTest extends CakeTestCase { $PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser'); $this->assertTrue(is_a($PluginUserCopy, 'RegistryPluginAppModel')); $this->assertSame($PluginUser, $PluginUserCopy); + CakePlugin::unload(); } }