Browse files

Fixing TestTask not being able to find plugin objects when baking tes…

…t skeletons interactively. Test case added. Fixes #1361
  • Loading branch information...
1 parent 5ffc84d commit e410509684a9aaeaa1fd7107459d80c4b290d220 @markstory markstory committed Dec 13, 2010
View
15 cake/console/libs/tasks/test.php
@@ -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) {
View
23 cake/tests/cases/console/libs/tasks/test.test.php
@@ -44,7 +44,7 @@
);
Mock::generatePartial(
'TestTask', 'MockTestTask',
- array('in', '_stop', 'err', 'out', 'createFile', 'isLoadableClass')
+ array('in', '_stop', 'err', 'out', 'hr', 'createFile', 'isLoadableClass')
);
/**
@@ -278,6 +278,7 @@ function startTest() {
*/
function endTest() {
ClassRegistry::flush();
+ App::build();
}
/**
@@ -561,6 +562,26 @@ function testBakeWithPlugin() {
}
/**
+ * 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
*
* @return void
View
3 cake/tests/cases/libs/model/db_acl.test.php
@@ -211,7 +211,8 @@ class DbAroUserTest extends CakeTestModel {
* @access public
*/
var $useTable = 'auth_users';
- /**
+
+/**
* bindNode method
*
* @param mixed $ref

0 comments on commit e410509

Please sign in to comment.