From da6e0c0589ac1045a7cf842c0135058b69e8b88f Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Thu, 12 May 2011 00:28:39 -0430 Subject: [PATCH] Updating the rest of the console tests to use the CakePlugin class --- lib/Cake/TestSuite/CakeTestLoader.php | 4 ++-- .../Case/Console/Command/Task/ControllerTaskTest.php | 9 ++++++--- .../Case/Console/Command/Task/FixtureTaskTest.php | 5 ++++- .../Case/Console/Command/Task/ModelTaskTest.php | 6 ++++-- .../tests/Case/Console/Command/Task/ViewTaskTest.php | 5 ++++- lib/Cake/tests/Case/Console/ShellDispatcherTest.php | 12 +++++++++++- lib/Cake/tests/Case/Console/TaskCollectionTest.php | 2 ++ 7 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestLoader.php b/lib/Cake/TestSuite/CakeTestLoader.php index 9fb47278a..158a0acdd 100644 --- a/lib/Cake/TestSuite/CakeTestLoader.php +++ b/lib/Cake/TestSuite/CakeTestLoader.php @@ -54,8 +54,8 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader { $result = CORE_TEST_CASES; } elseif (!empty($params['app'])) { $result = APP_TEST_CASES; - } else if (!empty($params['plugin'])) { - $pluginPath = App::pluginPath($params['plugin']); + } else if (!empty($params['plugin']) && CakePlugin::loaded($params['plugin'])) { + $pluginPath = CakePLugin::path($params['plugin']); $result = $pluginPath . 'tests' . DS . 'Case'; } return $result; diff --git a/lib/Cake/tests/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/tests/Case/Console/Command/Task/ControllerTaskTest.php index 4cfac5688..6cc6f01ff 100644 --- a/lib/Cake/tests/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/tests/Case/Console/Command/Task/ControllerTaskTest.php @@ -300,7 +300,9 @@ class ControllerTaskTest extends CakeTestCase { $components = array('Acl', 'Auth'); $uses = array('Comment', 'User'); - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'Controller' . DS . 'ArticlesController.php'; + //fake plugin path + CakePlugin::load('ControllerTest', array('path' => APP . 'plugins' . DS . 'ControllerTest' . DS)); + $path = APP . 'plugins' . DS . 'ControllerTest' . DS . 'Controller' . DS . 'ArticlesController.php'; $this->Task->expects($this->at(1))->method('createFile')->with( $path, @@ -313,11 +315,12 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->bake('Articles', '--actions--', array(), array(), array()); - $this->Task->plugin = 'controllerTest'; - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'Controller' . DS . 'ArticlesController.php'; + $this->Task->plugin = 'ControllerTest'; + $path = APP . 'plugins' . DS . 'ControllerTest' . DS . 'Controller' . DS . 'ArticlesController.php'; $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); + CakePlugin::unload(); } /** diff --git a/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php index a22631d99..ee86a3adf 100644 --- a/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php @@ -362,12 +362,15 @@ class FixtureTaskTest extends CakeTestCase { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; $this->Task->plugin = 'TestFixture'; - $filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'Fixture' . DS . 'ArticleFixture.php'; + $filename = APP . 'plugins' . DS . 'TestFixture' . DS . 'tests' . DS . 'Fixture' . DS . 'ArticleFixture.php'; + //fake plugin path + CakePlugin::load('TestFixture', array('path' => APP . 'plugins' . DS . 'TestFixture' . DS)); $this->Task->expects($this->at(0))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/Article/')); $result = $this->Task->generateFixtureFile('Article', array()); + CakePlugin::unload(); } } diff --git a/lib/Cake/tests/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/tests/Case/Console/Command/Task/ModelTaskTest.php index 48ae20ed6..08ae01f6a 100644 --- a/lib/Cake/tests/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/tests/Case/Console/Command/Task/ModelTaskTest.php @@ -743,9 +743,11 @@ STRINGEND; * @return void */ public function testBakeWithPlugin() { - $this->Task->plugin = 'controllerTest'; + $this->Task->plugin = 'ControllerTest'; - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'Model' . DS . 'BakeArticle.php'; + //fake plugin path + CakePlugin::load('ControllerTest', array('path' => APP . 'plugins' . DS . 'ControllerTest' . DS)); + $path = APP . 'plugins' . DS . 'ControllerTest' . DS . 'Model' . DS . 'BakeArticle.php'; $this->Task->expects($this->once())->method('createFile') ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/')); diff --git a/lib/Cake/tests/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/tests/Case/Console/Command/Task/ViewTaskTest.php index a0e92952f..c5577b19f 100644 --- a/lib/Cake/tests/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/tests/Case/Console/Command/Task/ViewTaskTest.php @@ -395,11 +395,14 @@ class ViewTaskTest extends CakeTestCase { $this->Task->plugin = 'TestTest'; $this->Task->name = 'View'; - $path = APP . 'plugins' . DS . 'test_test' . DS . 'View' . DS . 'view_task_comments' . DS . 'view.ctp'; + //fake plugin path + CakePlugin::load('TestTest', array('path' => APP . 'plugins' . DS . 'TestTest' . DS)); + $path = APP . 'plugins' . DS . 'TestTest' . DS . 'View' . DS . 'view_task_comments' . DS . 'view.ctp'; $this->Task->expects($this->once())->method('createFile') ->with($path, new PHPUnit_Framework_Constraint_IsAnything()); $this->Task->bake('view', true); + CakePlugin::unload(); } /** diff --git a/lib/Cake/tests/Case/Console/ShellDispatcherTest.php b/lib/Cake/tests/Case/Console/ShellDispatcherTest.php index f31af2f5b..e5bbfc78d 100644 --- a/lib/Cake/tests/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/tests/Case/Console/ShellDispatcherTest.php @@ -123,6 +123,16 @@ class ShellDispatcherTest extends CakeTestCase { LIBS . 'tests' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS ) ), true); + CakePlugin::loadAll(); + } + +/** + * tearDown method + * + * @return void + */ + public function tearDown() { + CakePlugin::unload(); } /** @@ -391,7 +401,7 @@ class ShellDispatcherTest extends CakeTestCase { $this->assertInstanceOf('SampleShell', $result); $Dispatcher = new TestShellDispatcher(); - $result = $Dispatcher->getShell('test_plugin.example'); + $result = $Dispatcher->getShell('TestPlugin.example'); $this->assertInstanceOf('ExampleShell', $result); } diff --git a/lib/Cake/tests/Case/Console/TaskCollectionTest.php b/lib/Cake/tests/Case/Console/TaskCollectionTest.php index bb961736f..3f5a40511 100644 --- a/lib/Cake/tests/Case/Console/TaskCollectionTest.php +++ b/lib/Cake/tests/Case/Console/TaskCollectionTest.php @@ -90,11 +90,13 @@ class TaskCollectionTest extends CakeTestCase { App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); + CakePlugin::load('TestPlugin'); $this->Tasks = new TaskCollection($shell, $dispatcher); $result = $this->Tasks->load('TestPlugin.OtherTask'); $this->assertInstanceOf('OtherTaskTask', $result, 'Task class is wrong.'); $this->assertInstanceOf('OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong'); + CakePlugin::unload(); } /**