mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating the rest of the console tests to use the CakePlugin class
This commit is contained in:
parent
e97b330463
commit
da6e0c0589
7 changed files with 33 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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/'));
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue