From e410509684a9aaeaa1fd7107459d80c4b290d220 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Dec 2010 22:00:37 -0500 Subject: [PATCH] Fixing TestTask not being able to find plugin objects when baking test skeletons interactively. Test case added. Fixes #1361 --- cake/console/libs/tasks/test.php | 15 +++++++++++- .../cases/console/libs/tasks/test.test.php | 23 ++++++++++++++++++- cake/tests/cases/libs/model/db_acl.test.php | 3 ++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cake/console/libs/tasks/test.php b/cake/console/libs/tasks/test.php index d90a1eb4a5b..ed9c7e4337d 100644 --- a/cake/console/libs/tasks/test.php +++ b/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) { diff --git a/cake/tests/cases/console/libs/tasks/test.test.php b/cake/tests/cases/console/libs/tasks/test.test.php index e660cdea8a6..b6f1e8c2a13 100644 --- a/cake/tests/cases/console/libs/tasks/test.test.php +++ b/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(); } /** @@ -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 * diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/cake/tests/cases/libs/model/db_acl.test.php index 73e9cf6a692..b970d2332e4 100644 --- a/cake/tests/cases/libs/model/db_acl.test.php +++ b/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