Skip to content

Commit

Permalink
Updating the rest of the console tests to use the CakePlugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 12, 2011
1 parent e97b330 commit da6e0c0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/TestSuite/CakeTestLoader.php
Expand Up @@ -54,8 +54,8 @@ protected static function _basePath($params) {
$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;
Expand Down
Expand Up @@ -300,7 +300,9 @@ public function testBakeWithPlugin() {
$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,
Expand All @@ -313,11 +315,12 @@ public function testBakeWithPlugin() {

$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();
}

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/Cake/tests/Case/Console/Command/Task/FixtureTaskTest.php
Expand Up @@ -362,12 +362,15 @@ public function testGeneratePluginFixtureFile() {
$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();
}

}
6 changes: 4 additions & 2 deletions lib/Cake/tests/Case/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -743,9 +743,11 @@ public function testBakeRelations() {
* @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/'));

Expand Down
5 changes: 4 additions & 1 deletion lib/Cake/tests/Case/Console/Command/Task/ViewTaskTest.php
Expand Up @@ -395,11 +395,14 @@ public function testBakeWithPlugin() {
$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();
}

/**
Expand Down
12 changes: 11 additions & 1 deletion lib/Cake/tests/Case/Console/ShellDispatcherTest.php
Expand Up @@ -123,6 +123,16 @@ public function setUp() {
LIBS . 'tests' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS
)
), true);
CakePlugin::loadAll();
}

/**
* tearDown method
*
* @return void
*/
public function tearDown() {
CakePlugin::unload();
}

/**
Expand Down Expand Up @@ -391,7 +401,7 @@ public function testGetShell() {
$this->assertInstanceOf('SampleShell', $result);

$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin.example');
$result = $Dispatcher->getShell('TestPlugin.example');
$this->assertInstanceOf('ExampleShell', $result);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/tests/Case/Console/TaskCollectionTest.php
Expand Up @@ -90,11 +90,13 @@ function testLoadPluginTask() {
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();
}

/**
Expand Down

0 comments on commit da6e0c0

Please sign in to comment.