Skip to content

Commit

Permalink
Fixing TestTask not being able to find plugin objects when baking tes…
Browse files Browse the repository at this point in the history
…t skeletons interactively. Test case added. Fixes #1361
  • Loading branch information
markstory committed Dec 14, 2010
1 parent 5ffc84d commit e410509
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
15 changes: 14 additions & 1 deletion cake/console/libs/tasks/test.php
Expand Up @@ -181,7 +181,20 @@ function getObjectType() {
* @access public
*/
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));
$keys = array();
foreach ($options as $key => $option) {
Expand Down
23 changes: 22 additions & 1 deletion cake/tests/cases/console/libs/tasks/test.test.php
Expand Up @@ -44,7 +44,7 @@
);
Mock::generatePartial(
'TestTask', 'MockTestTask',
array('in', '_stop', 'err', 'out', 'createFile', 'isLoadableClass')
array('in', '_stop', 'err', 'out', 'hr', 'createFile', 'isLoadableClass')
);

/**
Expand Down Expand Up @@ -278,6 +278,7 @@ function startTest() {
*/
function endTest() {
ClassRegistry::flush();
App::build();
}

/**
Expand Down Expand Up @@ -560,6 +561,26 @@ function testBakeWithPlugin() {
$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
*
Expand Down
3 changes: 2 additions & 1 deletion cake/tests/cases/libs/model/db_acl.test.php
Expand Up @@ -211,7 +211,8 @@ class DbAroUserTest extends CakeTestModel {
* @access public
*/
var $useTable = 'auth_users';
/**

/**
* bindNode method
*
* @param mixed $ref
Expand Down

0 comments on commit e410509

Please sign in to comment.