mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing TestTask not being able to find plugin objects when baking test skeletons interactively. Test case added. Fixes #1361
This commit is contained in:
parent
5ffc84d28a
commit
e410509684
3 changed files with 38 additions and 3 deletions
|
@ -181,7 +181,20 @@ class TestTask extends BakeTask {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getClassName($objectType) {
|
function getClassName($objectType) {
|
||||||
$options = App::objects(strtolower($objectType));
|
$type = strtolower($objectType);
|
||||||
|
if ($this->plugin) {
|
||||||
|
$path = Inflector::pluralize($type);
|
||||||
|
if ($type === 'helper') {
|
||||||
|
$path = 'views' . DS . $path;
|
||||||
|
} elseif ($type === 'component') {
|
||||||
|
$path = 'controllers' . DS . $path;
|
||||||
|
} elseif ($type === 'behavior') {
|
||||||
|
$path = 'models' . DS . $path;
|
||||||
|
}
|
||||||
|
$options = App::objects($type, App::pluginPath($this->plugin) . $path, false);
|
||||||
|
} else {
|
||||||
|
$options = App::objects($type);
|
||||||
|
}
|
||||||
$this->out(sprintf(__('Choose a %s class', true), $objectType));
|
$this->out(sprintf(__('Choose a %s class', true), $objectType));
|
||||||
$keys = array();
|
$keys = array();
|
||||||
foreach ($options as $key => $option) {
|
foreach ($options as $key => $option) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ Mock::generatePartial(
|
||||||
);
|
);
|
||||||
Mock::generatePartial(
|
Mock::generatePartial(
|
||||||
'TestTask', 'MockTestTask',
|
'TestTask', 'MockTestTask',
|
||||||
array('in', '_stop', 'err', 'out', 'createFile', 'isLoadableClass')
|
array('in', '_stop', 'err', 'out', 'hr', 'createFile', 'isLoadableClass')
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,6 +278,7 @@ class TestTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function endTest() {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -560,6 +561,26 @@ class TestTaskTest extends CakeTestCase {
|
||||||
$this->Task->bake('Helper', 'Form');
|
$this->Task->bake('Helper', 'Form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test interactive with plugins lists from the plugin
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testInteractiveWithPlugin() {
|
||||||
|
$testApp = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS;
|
||||||
|
App::build(array(
|
||||||
|
'plugins' => array($testApp)
|
||||||
|
), true);
|
||||||
|
|
||||||
|
$this->Task->plugin = 'TestPlugin';
|
||||||
|
$path = $testApp . 'test_plugin' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'other_helper.test.php';
|
||||||
|
$this->Task->setReturnValueAt(0, 'in', 5); //helper
|
||||||
|
$this->Task->setReturnValueAt(1, 'in', 1); //OtherHelper
|
||||||
|
$this->Task->expectAt(0, 'createFile', array($path, '*'));
|
||||||
|
$this->Task->expectAt(9, 'out', array('1. OtherHelper'));
|
||||||
|
$this->Task->execute();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test filename generation for each type + plugins
|
* Test filename generation for each type + plugins
|
||||||
*
|
*
|
||||||
|
|
|
@ -211,7 +211,8 @@ class DbAroUserTest extends CakeTestModel {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useTable = 'auth_users';
|
var $useTable = 'auth_users';
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* bindNode method
|
* bindNode method
|
||||||
*
|
*
|
||||||
* @param mixed $ref
|
* @param mixed $ref
|
||||||
|
|
Loading…
Add table
Reference in a new issue