diff --git a/src/Console/Command/BakeShell.php b/src/Console/Command/BakeShell.php index adb85c60456..ac7ee1f07d8 100644 --- a/src/Console/Command/BakeShell.php +++ b/src/Console/Command/BakeShell.php @@ -242,7 +242,7 @@ public function getOptionParser() { 'help' => 'Database connection to use in conjunction with `bake all`.', 'short' => 'c', 'default' => 'default' - ])->addOption('theme', [ + ])->addOption('template', [ 'short' => 't', 'help' => 'Theme to use when baking code.' ]); diff --git a/src/Console/Command/Task/BakeTask.php b/src/Console/Command/Task/BakeTask.php index fe34986388f..c05fe8413bd 100644 --- a/src/Console/Command/Task/BakeTask.php +++ b/src/Console/Command/Task/BakeTask.php @@ -177,10 +177,10 @@ public function getOptionParser() { 'short' => 'c', 'default' => 'default', 'help' => 'The datasource connection to get data from.' - ])->addOption('theme', [ + ])->addOption('template', [ 'short' => 't', 'default' => 'default', - 'help' => 'Theme to use when baking code.' + 'help' => 'Template to use when baking code.' ]); return $parser; } diff --git a/src/Console/Command/Task/ProjectTask.php b/src/Console/Command/Task/ProjectTask.php index 751856d6ed0..af1d5320e46 100644 --- a/src/Console/Command/Task/ProjectTask.php +++ b/src/Console/Command/Task/ProjectTask.php @@ -166,9 +166,9 @@ public function getOptionParser() { ])->addOption('empty', [ 'boolean' => true, 'help' => 'Create empty files in each of the directories. Good if you are using git' - ])->addOption('theme', [ + ])->addOption('template', [ 'short' => 't', - 'help' => 'Theme to use when baking code.' + 'help' => 'Template to use when baking code.' ])->addOption('composer', [ 'default' => ROOT . '/composer.phar', 'help' => 'The path to the composer executable.' diff --git a/src/Console/Command/Task/TemplateTask.php b/src/Console/Command/Task/TemplateTask.php index 4868a06561f..d4545f0b3a8 100644 --- a/src/Console/Command/Task/TemplateTask.php +++ b/src/Console/Command/Task/TemplateTask.php @@ -31,7 +31,7 @@ class TemplateTask extends Shell { /** * Paths to look for templates on. - * Contains a list of $theme => $path + * Contains a list of $template => $path * * @var array */ @@ -43,30 +43,30 @@ class TemplateTask extends Shell { * @return void */ public function initialize() { - $this->templatePaths = $this->_findThemes(); + $this->templatePaths = $this->_findTemplates(); } /** - * Find the paths to all the installed shell themes in the app. + * Find the paths to all the installed shell templates in the app. * - * Bake themes are directories not named `skel` inside a `Console/Templates` path. + * Bake templates are directories under `Template/Bake` path. * They are listed in this order: app -> plugin -> default * - * @return array Array of bake themes that are installed. + * @return array Array of bake templates that are installed. */ - protected function _findThemes() { - $paths = App::path('Console'); + protected function _findTemplates() { + $paths = App::path('Template'); $plugins = App::objects('Plugin'); foreach ($plugins as $plugin) { - $paths[] = $this->_pluginPath($plugin) . 'src/Console/'; + $paths[] = $this->_pluginPath($plugin) . 'src' . DS . 'Template' . DS; } - $core = current(App::core('Console')); - $Folder = new Folder($core . 'Templates/default'); + $core = current(App::core('Template')); + $Folder = new Folder($core . 'Bake' . DS . 'default'); $contents = $Folder->read(); - $themeFolders = $contents[0]; + $templateFolders = $contents[0]; $paths[] = $core; @@ -74,26 +74,26 @@ protected function _findThemes() { $paths[$i] = rtrim($path, DS) . DS; } - $this->_io->verbose('Found the following bake themes:'); + $this->_io->verbose('Found the following bake templates:'); - $themes = []; + $templates = []; foreach ($paths as $path) { - $Folder = new Folder($path . 'Templates', false); + $Folder = new Folder($path . 'Bake', false); $contents = $Folder->read(); $subDirs = $contents[0]; foreach ($subDirs as $dir) { - $Folder = new Folder($path . 'Templates/' . $dir); + $Folder = new Folder($path . 'Bake' . DS . $dir); $contents = $Folder->read(); $subDirs = $contents[0]; - if (array_intersect($contents[0], $themeFolders)) { - $templateDir = $path . 'Templates/' . $dir . DS; - $themes[$dir] = $templateDir; + if (array_intersect($contents[0], $templateFolders)) { + $templateDir = $path . 'Bake' . DS . $dir . DS; + $templates[$dir] = $templateDir; $this->_io->verbose(sprintf("- %s -> %s", $dir, $templateDir)); } } } - return $themes; + return $templates; } /** @@ -111,8 +111,8 @@ public function generate($directory, $filename, $vars = null) { if (empty($this->templatePaths)) { $this->initialize(); } - $themePath = $this->getThemePath(); - $templateFile = $this->_findTemplate($themePath, $directory, $filename); + $templatePath = $this->getTemplatePath(); + $templateFile = $this->_findTemplate($templatePath, $directory, $filename); if ($templateFile) { extract($this->viewVars); ob_start(); @@ -125,29 +125,29 @@ public function generate($directory, $filename, $vars = null) { } /** - * Find the theme name for the current operation. - * If there is only one theme in $templatePaths it will be used. - * If there is a -theme param in the cli args, it will be used. - * If there is more than one installed theme user interaction will happen + * Find the template name for the current operation. + * If there is only one template in $templatePaths it will be used. + * If there is a -template param in the cli args, it will be used. + * If there is more than one installed template user interaction will happen * - * @return string returns the path to the selected theme. - * @throws \RuntimeException When the chosen theme cannot be found. + * @return string returns the path to the selected template. + * @throws \RuntimeException When the chosen template cannot be found. */ - public function getThemePath() { - if (empty($this->params['theme'])) { - $this->params['theme'] = 'default'; + public function getTemplatePath() { + if (empty($this->params['template'])) { + $this->params['template'] = 'default'; } - if (!isset($this->templatePaths[$this->params['theme']])) { - $msg = sprintf('Unable to locate "%s" bake theme templates.', $this->params['theme']); + if (!isset($this->templatePaths[$this->params['template']])) { + $msg = sprintf('Unable to locate "%s" bake template', $this->params['template']); throw new \RuntimeException($msg); } - $this->_io->verbose(sprintf('Using "%s" bake theme', $this->params['theme'])); - return $this->templatePaths[$this->params['theme']]; + $this->_io->verbose(sprintf('Using "%s" bake template', $this->params['template'])); + return $this->templatePaths[$this->params['template']]; } /** * Find a template inside a directory inside a path. - * Will scan all other theme dirs if the template is not found in the first directory. + * Will scan all other template dirs if the template is not found in the first directory. * * @param string $path The initial path to look for the file on. If it is not found fallbacks will be used. * @param string $directory Subdirectory to look for ie. 'views', 'objects' @@ -155,9 +155,9 @@ public function getThemePath() { * @return string filename will exit program if template is not found. */ protected function _findTemplate($path, $directory, $filename) { - $themeFile = $path . $directory . DS . $filename . '.ctp'; - if (file_exists($themeFile)) { - return $themeFile; + $templateFile = $path . $directory . DS . $filename . '.ctp'; + if (file_exists($templateFile)) { + return $templateFile; } foreach ($this->templatePaths as $path) { $templatePath = $path . $directory . DS . $filename . '.ctp'; diff --git a/src/Console/Command/Task/ViewTask.php b/src/Console/Command/Task/ViewTask.php index ab5087778cb..3ad29892367 100644 --- a/src/Console/Command/Task/ViewTask.php +++ b/src/Console/Command/Task/ViewTask.php @@ -380,19 +380,19 @@ public function getTemplate($action) { if (!empty($this->template) && $action != $this->template) { return $this->template; } - $themePath = $this->Template->getThemePath(); + $templatePath = $this->Template->getTemplatePath(); if (!empty($this->params['prefix'])) { $prefixed = Inflector::underscore($this->params['prefix']) . '_' . $action; - if (file_exists($themePath . 'views/' . $prefixed . '.ctp')) { + if (file_exists($templatePath . 'views/' . $prefixed . '.ctp')) { return $prefixed; } $generic = preg_replace('/(.*)(_add|_edit)$/', '\1_form', $prefixed); - if (file_exists($themePath . 'views/' . $generic . '.ctp')) { + if (file_exists($templatePath . 'views/' . $generic . '.ctp')) { return $generic; } } - if (file_exists($themePath . 'views/' . $action . '.ctp')) { + if (file_exists($templatePath . 'views/' . $action . '.ctp')) { return $action; } if (in_array($action, ['add', 'edit'])) { diff --git a/src/Controller/Component/SessionComponent.php b/src/Controller/Component/SessionComponent.php index 9ac264a4860..4387cfedbd8 100644 --- a/src/Controller/Component/SessionComponent.php +++ b/src/Controller/Component/SessionComponent.php @@ -117,6 +117,7 @@ public function check($name) { * @param array $params Parameters to be sent to layout as view variables * @param string $key Message key, default is 'flash' * @return void + * @deprecated 3.0 Use FlashComponent::set() instead. * @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages */ public function setFlash($message, $element = null, array $params = array(), $key = 'flash') { diff --git a/src/Console/Templates/default/actions/controller_actions.ctp b/src/Template/Bake/default/actions/controller_actions.ctp similarity index 100% rename from src/Console/Templates/default/actions/controller_actions.ctp rename to src/Template/Bake/default/actions/controller_actions.ctp diff --git a/src/Console/Templates/default/classes/behavior.ctp b/src/Template/Bake/default/classes/behavior.ctp similarity index 100% rename from src/Console/Templates/default/classes/behavior.ctp rename to src/Template/Bake/default/classes/behavior.ctp diff --git a/src/Console/Templates/default/classes/cell.ctp b/src/Template/Bake/default/classes/cell.ctp similarity index 100% rename from src/Console/Templates/default/classes/cell.ctp rename to src/Template/Bake/default/classes/cell.ctp diff --git a/src/Console/Templates/default/classes/component.ctp b/src/Template/Bake/default/classes/component.ctp similarity index 100% rename from src/Console/Templates/default/classes/component.ctp rename to src/Template/Bake/default/classes/component.ctp diff --git a/src/Console/Templates/default/classes/controller.ctp b/src/Template/Bake/default/classes/controller.ctp similarity index 100% rename from src/Console/Templates/default/classes/controller.ctp rename to src/Template/Bake/default/classes/controller.ctp diff --git a/src/Console/Templates/default/classes/entity.ctp b/src/Template/Bake/default/classes/entity.ctp similarity index 100% rename from src/Console/Templates/default/classes/entity.ctp rename to src/Template/Bake/default/classes/entity.ctp diff --git a/src/Console/Templates/default/classes/fixture.ctp b/src/Template/Bake/default/classes/fixture.ctp similarity index 100% rename from src/Console/Templates/default/classes/fixture.ctp rename to src/Template/Bake/default/classes/fixture.ctp diff --git a/src/Console/Templates/default/classes/helper.ctp b/src/Template/Bake/default/classes/helper.ctp similarity index 100% rename from src/Console/Templates/default/classes/helper.ctp rename to src/Template/Bake/default/classes/helper.ctp diff --git a/src/Console/Templates/default/classes/shell.ctp b/src/Template/Bake/default/classes/shell.ctp similarity index 100% rename from src/Console/Templates/default/classes/shell.ctp rename to src/Template/Bake/default/classes/shell.ctp diff --git a/src/Console/Templates/default/classes/table.ctp b/src/Template/Bake/default/classes/table.ctp similarity index 100% rename from src/Console/Templates/default/classes/table.ctp rename to src/Template/Bake/default/classes/table.ctp diff --git a/src/Console/Templates/default/classes/test.ctp b/src/Template/Bake/default/classes/test.ctp similarity index 100% rename from src/Console/Templates/default/classes/test.ctp rename to src/Template/Bake/default/classes/test.ctp diff --git a/src/Console/Templates/default/config/routes.ctp b/src/Template/Bake/default/config/routes.ctp similarity index 100% rename from src/Console/Templates/default/config/routes.ctp rename to src/Template/Bake/default/config/routes.ctp diff --git a/src/Console/Templates/default/test/bootstrap.ctp b/src/Template/Bake/default/test/bootstrap.ctp similarity index 100% rename from src/Console/Templates/default/test/bootstrap.ctp rename to src/Template/Bake/default/test/bootstrap.ctp diff --git a/src/Console/Templates/default/test/phpunit.xml.ctp b/src/Template/Bake/default/test/phpunit.xml.ctp similarity index 100% rename from src/Console/Templates/default/test/phpunit.xml.ctp rename to src/Template/Bake/default/test/phpunit.xml.ctp diff --git a/src/Console/Templates/default/views/form.ctp b/src/Template/Bake/default/views/form.ctp similarity index 100% rename from src/Console/Templates/default/views/form.ctp rename to src/Template/Bake/default/views/form.ctp diff --git a/src/Console/Templates/default/views/index.ctp b/src/Template/Bake/default/views/index.ctp similarity index 100% rename from src/Console/Templates/default/views/index.ctp rename to src/Template/Bake/default/views/index.ctp diff --git a/src/Console/Templates/default/views/view.ctp b/src/Template/Bake/default/views/view.ctp similarity index 100% rename from src/Console/Templates/default/views/view.ctp rename to src/Template/Bake/default/views/view.ctp diff --git a/src/TestSuite/ControllerTestCase.php b/src/TestSuite/ControllerTestCase.php index 79406b4334a..2a9bc20ae61 100644 --- a/src/TestSuite/ControllerTestCase.php +++ b/src/TestSuite/ControllerTestCase.php @@ -254,10 +254,14 @@ protected function _testAction($url = '', $options = array()) { $request = $this->getMock( 'Cake\Network\Request', - array('_readInput'), + array('_readInput', 'method'), array($requestData) ); + $request->expects($this->any()) + ->method('method') + ->will($this->returnValue($method)); + if (is_string($options['data'])) { $request->expects($this->any()) ->method('_readInput') diff --git a/src/View/Helper/SessionHelper.php b/src/View/Helper/SessionHelper.php index dcd1d886762..547dca08924 100644 --- a/src/View/Helper/SessionHelper.php +++ b/src/View/Helper/SessionHelper.php @@ -111,6 +111,7 @@ public function check($name) { * @param array $attrs Additional attributes to use for the creation of this flash message. * Supports the 'params', and 'element' keys that are used in the helper. * @return string + * @deprecated 3.0 Use FlashHelper::render() instead. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html#SessionHelper::flash */ public function flash($key = 'flash', $attrs = []) { diff --git a/tests/TestCase/Console/Command/CompletionShellTest.php b/tests/TestCase/Console/Command/CompletionShellTest.php index 6b5ff378043..5d53c4f32ae 100644 --- a/tests/TestCase/Console/Command/CompletionShellTest.php +++ b/tests/TestCase/Console/Command/CompletionShellTest.php @@ -151,7 +151,7 @@ public function testOptions() { $this->Shell->runCommand(['options', 'bake']); $output = $this->out->output; - $expected = "--help -h --verbose -v --quiet -q --connection -c --theme -t\n"; + $expected = "--help -h --verbose -v --quiet -q --connection -c --template -t\n"; $this->assertTextEquals($expected, $output); } diff --git a/tests/TestCase/Console/Command/Task/TemplateTaskTest.php b/tests/TestCase/Console/Command/Task/TemplateTaskTest.php index 1bf11cfceaa..5f14c44ddba 100644 --- a/tests/TestCase/Console/Command/Task/TemplateTaskTest.php +++ b/tests/TestCase/Console/Command/Task/TemplateTaskTest.php @@ -49,52 +49,52 @@ public function tearDown() { } /** - * test finding themes installed in + * test finding templates installed in * * @return void */ - public function testFindingInstalledThemesForBake() { - $consoleLibs = CAKE . 'Console' . DS; + public function testFindingInstalledTemplatesForBake() { + $consoleLibs = CAKE . 'Template' . DS; $this->Task->initialize(); - $this->assertPathEquals($this->Task->templatePaths['default'], $consoleLibs . 'Templates/default/'); + $this->assertPathEquals($this->Task->templatePaths['default'], $consoleLibs . 'Bake/default/'); } /** - * test using an invalid theme name. + * test using an invalid template name. * * @expectedException \RuntimeException - * @expectedExceptionMessage Unable to locate "nope" bake theme + * @expectedExceptionMessage Unable to locate "nope" bake template * @return void */ - public function testGetThemePathInvalid() { - $defaultTheme = CAKE . 'Console/Templates/default/'; - $this->Task->templatePaths = ['default' => $defaultTheme]; - $this->Task->params['theme'] = 'nope'; - $this->Task->getThemePath(); + public function testGetTemplatePathInvalid() { + $defaultTemplate = CAKE . 'Template/Bake/default/'; + $this->Task->templatePaths = ['default' => $defaultTemplate]; + $this->Task->params['template'] = 'nope'; + $this->Task->getTemplatePath(); } /** - * test getting the correct theme name. Ensure that with only one theme, or a theme param - * that the user is not bugged. If there are more, find and return the correct theme name + * test getting the correct template name. Ensure that with only one template, or a template param + * that the user is not bugged. If there are more, find and return the correct template name * * @return void */ - public function testGetThemePath() { - $defaultTheme = CAKE . 'Console/Templates/default/'; - $this->Task->templatePaths = ['default' => $defaultTheme]; + public function testGetTemplatePath() { + $defaultTemplate = CAKE . 'Template/Bake/default/'; + $this->Task->templatePaths = ['default' => $defaultTemplate]; - $result = $this->Task->getThemePath(); - $this->assertEquals($defaultTheme, $result); + $result = $this->Task->getTemplatePath(); + $this->assertEquals($defaultTemplate, $result); - $this->Task->templatePaths = ['other' => '/some/path', 'default' => $defaultTheme]; - $this->Task->params['theme'] = 'other'; - $result = $this->Task->getThemePath(); + $this->Task->templatePaths = ['other' => '/some/path', 'default' => $defaultTemplate]; + $this->Task->params['template'] = 'other'; + $result = $this->Task->getTemplatePath(); $this->assertEquals('/some/path', $result); $this->Task->params = array(); - $result = $this->Task->getThemePath(); - $this->assertEquals($defaultTheme, $result); - $this->assertEquals('default', $this->Task->params['theme']); + $result = $this->Task->getTemplatePath(); + $this->assertEquals($defaultTemplate, $result); + $this->assertEquals('default', $this->Task->params['template']); } /** @@ -112,14 +112,14 @@ public function testGenerate() { } /** - * test generate with a missing template in the chosen theme. + * test generate with a missing template in the chosen template. * ensure fallback to default works. * * @return void */ public function testGenerateWithTemplateFallbacks() { $this->Task->initialize(); - $this->Task->params['theme'] = 'test'; + $this->Task->params['template'] = 'test'; $this->Task->set(array( 'name' => 'Article', 'model' => 'Article', diff --git a/tests/TestCase/Console/Command/Task/ViewTaskTest.php b/tests/TestCase/Console/Command/Task/ViewTaskTest.php index aefc473694f..6e55c9456ac 100644 --- a/tests/TestCase/Console/Command/Task/ViewTaskTest.php +++ b/tests/TestCase/Console/Command/Task/ViewTaskTest.php @@ -94,7 +94,7 @@ class ViewTaskTest extends TestCase { /** * setUp method * - * Ensure that the default theme is used + * Ensure that the default template is used * * @return void */ @@ -124,8 +124,8 @@ protected function _setupTask($methods) { $this->Task->Template = new TemplateTask($io); $this->Task->Model = $this->getMock('Cake\Console\Command\Task\ModelTask', [], [$io]); - $this->Task->Template->params['theme'] = 'default'; - $this->Task->Template->templatePaths = ['default' => CAKE . 'Console/Templates/default/']; + $this->Task->Template->params['template'] = 'default'; + $this->Task->Template->templatePaths = ['default' => CAKE . 'Template/Bake/default/']; } /** @@ -707,9 +707,9 @@ public function testGetTemplatePrefixed() { $this->assertEquals('form', $result); $this->Task->Template->templatePaths = array( - 'test' => CORE_TESTS . '/test_app/TestApp/Console/Templates/test/' + 'test' => CORE_TESTS . '/test_app/TestApp/Template/Bake/test/' ); - $this->Task->Template->params['theme'] = 'test'; + $this->Task->Template->params['template'] = 'test'; $result = $this->Task->getTemplate('edit'); $this->assertEquals('admin_edit', $result); diff --git a/tests/TestCase/TestSuite/ControllerTestCaseTest.php b/tests/TestCase/TestSuite/ControllerTestCaseTest.php index 9b660060ea3..75730c965bf 100644 --- a/tests/TestCase/TestSuite/ControllerTestCaseTest.php +++ b/tests/TestCase/TestSuite/ControllerTestCaseTest.php @@ -214,6 +214,24 @@ public function testTestAction() { $this->assertEquals($expected, $results); } +/** + * Tests testAction with call to request::method() + * + * @return void + */ + public function testTestActionWithRequestMethod() { + $Controller = $this->Case->generate('TestsApps'); + $this->Case->testAction('/tests_apps/index', [ + 'method' => 'get' + ]); + $this->assertSame('GET', $this->Case->controller->request->method()); + + $this->Case->testAction('/tests_apps/set_action', [ + 'method' => 'post' + ]); + $this->assertSame('POST', $this->Case->controller->request->method()); + } + /** * Test testAction() with prefix routes. * diff --git a/tests/TestCase/Utility/FolderTest.php b/tests/TestCase/Utility/FolderTest.php index f7aabae1a9d..246030fbe6a 100644 --- a/tests/TestCase/Utility/FolderTest.php +++ b/tests/TestCase/Utility/FolderTest.php @@ -180,7 +180,7 @@ public function testRecursiveCreateFailure() { * @return void */ public function testOperations() { - $path = CAKE . 'Console/Templates'; + $path = CAKE . 'Template/Bake'; $Folder = new Folder($path); $result = is_dir($Folder->pwd()); diff --git a/tests/test_app/Plugin/TestPlugin/src/Console/Templates/empty b/tests/test_app/Plugin/TestPlugin/src/Template/Bake/empty similarity index 100% rename from tests/test_app/Plugin/TestPlugin/src/Console/Templates/empty rename to tests/test_app/Plugin/TestPlugin/src/Template/Bake/empty diff --git a/tests/test_app/Plugin/TestPluginTwo/src/Console/Templates/empty b/tests/test_app/Plugin/TestPluginTwo/src/Template/Bake/empty similarity index 100% rename from tests/test_app/Plugin/TestPluginTwo/src/Console/Templates/empty rename to tests/test_app/Plugin/TestPluginTwo/src/Template/Bake/empty diff --git a/tests/test_app/TestApp/Console/Templates/test/classes/test_object.ctp b/tests/test_app/TestApp/Template/Bake/test/classes/test_object.ctp similarity index 100% rename from tests/test_app/TestApp/Console/Templates/test/classes/test_object.ctp rename to tests/test_app/TestApp/Template/Bake/test/classes/test_object.ctp diff --git a/tests/test_app/TestApp/Console/Templates/test/views/admin_edit.ctp b/tests/test_app/TestApp/Template/Bake/test/views/admin_edit.ctp similarity index 100% rename from tests/test_app/TestApp/Console/Templates/test/views/admin_edit.ctp rename to tests/test_app/TestApp/Template/Bake/test/views/admin_edit.ctp diff --git a/tests/test_app/TestApp/Console/Templates/test/views/admin_form.ctp b/tests/test_app/TestApp/Template/Bake/test/views/admin_form.ctp similarity index 100% rename from tests/test_app/TestApp/Console/Templates/test/views/admin_form.ctp rename to tests/test_app/TestApp/Template/Bake/test/views/admin_form.ctp