diff --git a/composer.json b/composer.json
index 3d751a1c3..cca6a2a9f 100644
--- a/composer.json
+++ b/composer.json
@@ -22,7 +22,7 @@
"cakephp/cakephp": ">=3.2.0"
},
"require-dev": {
- "cakephp/cakephp-codesniffer": "dev-master",
+ "cakephp/cakephp-codesniffer": "^2.1",
"phpunit/phpunit": "*"
},
"autoload": {
diff --git a/src/Shell/BakeShell.php b/src/Shell/BakeShell.php
index 2a776cc41..14fd240de 100644
--- a/src/Shell/BakeShell.php
+++ b/src/Shell/BakeShell.php
@@ -79,6 +79,7 @@ public function main()
array_shift($args);
$args = implode($args, ' ');
$this->out(sprintf(' `bin/cake bake template %s`', $args), 2);
+
return false;
}
@@ -86,6 +87,7 @@ public function main()
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
+
return false;
}
$this->out('The following commands can be used to generate skeleton code for your application.', 2);
@@ -102,6 +104,7 @@ public function main()
}
$this->out('');
$this->out('By using `cake bake [name]` you can invoke a specific bake task.');
+
return false;
}
@@ -158,6 +161,7 @@ protected function _findTasks($tasks, $path, $namespace, $prefix = null)
$fullName = ($prefix ? $prefix . '.' : '') . $name;
$tasks[$name] = $fullName;
}
+
return $tasks;
}
@@ -179,6 +183,7 @@ protected function _findClassFiles($path, $namespace)
$name = $item->getBasename('.php');
$candidates[] = $namespace . '\Shell\Task\\' . $name;
}
+
return $candidates;
}
@@ -204,6 +209,7 @@ protected function _findTaskClasses($files)
}
$classes[] = $className;
}
+
return $classes;
}
@@ -229,6 +235,7 @@ public function all($name = null)
$this->out('- ' . $table);
}
$this->out('Run `cake bake all [name]` to generate skeleton files.');
+
return false;
}
@@ -253,6 +260,7 @@ public function all($name = null)
});
$this->out('Bake All complete.', 1, Shell::QUIET);
+
return true;
}
diff --git a/src/Shell/Task/BakeTask.php b/src/Shell/Task/BakeTask.php
index 7d59baccd..7557008aa 100644
--- a/src/Shell/Task/BakeTask.php
+++ b/src/Shell/Task/BakeTask.php
@@ -90,6 +90,7 @@ protected function _getPrefix()
return '';
}
$parts = explode('/', $prefix);
+
return implode('/', array_map([$this, '_camelize'], $parts));
}
@@ -109,6 +110,7 @@ public function getPath()
if ($prefix) {
$path .= $prefix . DS;
}
+
return str_replace('/', DS, $path);
}
@@ -124,6 +126,7 @@ public function main()
$this->plugin = $this->params['plugin'];
if (strpos($this->plugin, '\\')) {
$this->abort('Invalid plugin namespace separator, please use / instead of \ for plugins.');
+
return;
}
}
@@ -154,6 +157,7 @@ public function callProcess($command)
);
if (!is_resource($process)) {
$this->abort('Could not start subprocess.');
+
return;
}
fclose($pipes[0]);
@@ -186,6 +190,7 @@ protected function _getName($name)
list($plugin, $name) = pluginSplit($name);
$this->plugin = $this->params['plugin'] = $plugin;
}
+
return $name;
}
diff --git a/src/Shell/Task/BakeTemplateTask.php b/src/Shell/Task/BakeTemplateTask.php
index fe0f87f5c..1397b1b55 100644
--- a/src/Shell/Task/BakeTemplateTask.php
+++ b/src/Shell/Task/BakeTemplateTask.php
@@ -89,6 +89,7 @@ public function generate($template, $vars = null)
return $this->View->render($template);
} catch (MissingTemplateException $e) {
$this->_io->verbose(sprintf('No bake template found for "%s"', $template));
+
return '';
}
}
diff --git a/src/Shell/Task/CellTask.php b/src/Shell/Task/CellTask.php
index fe88eee23..dea0c46fc 100644
--- a/src/Shell/Task/CellTask.php
+++ b/src/Shell/Task/CellTask.php
@@ -54,11 +54,12 @@ public function template()
* Bake the Cell class and template file.
*
* @param string $name The name of the cell to make.
- * @return void
+ * @return string
*/
public function bake($name)
{
$this->bakeTemplate($name);
+
return parent::bake($name);
}
diff --git a/src/Shell/Task/ControllerTask.php b/src/Shell/Task/ControllerTask.php
index 7a7d36415..6db82bde8 100644
--- a/src/Shell/Task/ControllerTask.php
+++ b/src/Shell/Task/ControllerTask.php
@@ -46,7 +46,7 @@ class ControllerTask extends BakeTask
* Execution method always used for tasks
*
* @param string|null $name The name of the controller to bake.
- * @return void
+ * @return null|bool
*/
public function main($name = null)
{
@@ -58,6 +58,7 @@ public function main($name = null)
foreach ($this->listAll() as $table) {
$this->out('- ' . $this->_camelize($table));
}
+
return true;
}
@@ -149,6 +150,7 @@ public function bake($controllerName)
$out = $this->bakeController($controllerName, $data);
$this->bakeTest($controllerName);
+
return $out;
}
@@ -179,6 +181,7 @@ public function bakeController($controllerName, array $data)
$path = $this->getPath();
$filename = $path . $controllerName . 'Controller.php';
$this->createFile($filename, $contents);
+
return $contents;
}
@@ -186,7 +189,7 @@ public function bakeController($controllerName, array $data)
* Assembles and writes a unit test file
*
* @param string $className Controller class name
- * @return string Baked test
+ * @return void|string Baked test
*/
public function bakeTest($className)
{
@@ -199,6 +202,7 @@ public function bakeTest($className)
if ($prefix) {
$className = str_replace('/', '\\', $prefix) . '\\' . $className;
}
+
return $this->Test->bake('Controller', $className);
}
@@ -214,6 +218,7 @@ public function getComponents()
$components = explode(',', $this->params['components']);
$components = array_values(array_filter(array_map('trim', $components)));
}
+
return $components;
}
@@ -229,6 +234,7 @@ public function getHelpers()
$helpers = explode(',', $this->params['helpers']);
$helpers = array_values(array_filter(array_map('trim', $helpers)));
}
+
return $helpers;
}
@@ -240,6 +246,7 @@ public function getHelpers()
public function listAll()
{
$this->Model->connection = $this->connection;
+
return $this->Model->listUnskipped();
}
diff --git a/src/Shell/Task/FixtureTask.php b/src/Shell/Task/FixtureTask.php
index bb221f44a..10ae23a80 100644
--- a/src/Shell/Task/FixtureTask.php
+++ b/src/Shell/Task/FixtureTask.php
@@ -51,6 +51,7 @@ public function getPath()
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . 'tests/' . $dir;
}
+
return str_replace('/', DS, $path);
}
@@ -97,7 +98,7 @@ public function getOptionParser()
* Handles dispatching to interactive, named, or all processes.
*
* @param string|null $name The name of the fixture to bake.
- * @return void
+ * @return null|bool
*/
public function main($name = null)
{
@@ -109,6 +110,7 @@ public function main($name = null)
foreach ($this->Model->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
+
return true;
}
@@ -193,6 +195,7 @@ public function bake($model, $useTable = null)
if (!empty($this->params['records'])) {
$records = $this->_makeRecordString($this->_getRecordsFromTable($model, $useTable));
}
+
return $this->generateFixtureFile($model, compact('records', 'table', 'schema', 'import'));
}
@@ -230,6 +233,7 @@ public function generateFixtureFile($model, array $otherVars)
$this->createFile($path . $filename, $content);
$emptyFile = $path . 'empty';
$this->_deleteEmptyFile($emptyFile);
+
return $content;
}
@@ -272,6 +276,7 @@ protected function _generateSchema(Table $table)
}
$content .= " '_options' => [\n" . implode(",\n", $options) . "\n ],\n";
}
+
return "[\n$content ]";
}
@@ -302,6 +307,7 @@ protected function _values($values)
}
}
}
+
return $vals;
}
@@ -373,6 +379,7 @@ protected function _generateRecords(Table $table, $recordCount = 1)
}
$records[] = $record;
}
+
return $records;
}
@@ -402,6 +409,7 @@ protected function _makeRecordString($records)
$out .= "\n ],\n";
}
$out .= " ]";
+
return $out;
}
diff --git a/src/Shell/Task/MailerTask.php b/src/Shell/Task/MailerTask.php
index ab31e016e..299d76842 100644
--- a/src/Shell/Task/MailerTask.php
+++ b/src/Shell/Task/MailerTask.php
@@ -56,11 +56,12 @@ public function template()
* Bake the Mailer class and html/text layout files.
*
* @param string $name The name of the mailer to make.
- * @return void
+ * @return string
*/
public function bake($name)
{
$this->bakeLayouts($name);
+
return parent::bake($name);
}
diff --git a/src/Shell/Task/ModelTask.php b/src/Shell/Task/ModelTask.php
index 18f694d0d..470b59787 100644
--- a/src/Shell/Task/ModelTask.php
+++ b/src/Shell/Task/ModelTask.php
@@ -90,6 +90,7 @@ public function main($name = null)
foreach ($this->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
+
return;
}
@@ -116,6 +117,8 @@ public function bake($name)
/**
* Get table context for baking a given table.
*
+ * @param \Cake\ORM\Table $tableObject The model name to generate.
+ * @param string $table The table name for the model being baked.
* @param string $name The model name to generate.
* @return array
*/
@@ -175,6 +178,7 @@ public function getTableObject($className, $table)
if (TableRegistry::exists($className)) {
return TableRegistry::get($className);
}
+
return TableRegistry::get($className, [
'name' => $className,
'table' => $table,
@@ -210,11 +214,13 @@ public function getAssociations(Table $table)
$this->err(
'Bake cannot generate associations for composite primary keys at this time.'
);
+
return $associations;
}
$associations = $this->findHasMany($table, $associations);
$associations = $this->findBelongsToMany($table, $associations);
+
return $associations;
}
@@ -287,6 +293,7 @@ public function findBelongsTo($model, array $associations)
}
$associations['belongsTo'][] = $assoc;
}
+
return $associations;
}
@@ -310,9 +317,11 @@ public function findTableReferencedBy($schema, $keyField)
if (!isset($constraintInfo['references'])) {
continue;
}
+
return $constraintInfo['references'][0];
}
}
+
return null;
}
@@ -367,6 +376,7 @@ public function findHasMany($model, array $associations)
}
}
}
+
return $associations;
}
@@ -408,6 +418,7 @@ public function findBelongsToMany($model, array $associations)
$associations['belongsToMany'][] = $assoc;
}
}
+
return $associations;
}
@@ -422,6 +433,7 @@ public function getDisplayField($model)
if (!empty($this->params['display-field'])) {
return $this->params['display-field'];
}
+
return $model->displayField();
}
@@ -435,8 +447,10 @@ public function getPrimaryKey($model)
{
if (!empty($this->params['primary-key'])) {
$fields = explode(',', $this->params['primary-key']);
+
return array_values(array_filter(array_map('trim', $fields)));
}
+
return (array)$model->primaryKey();
}
@@ -518,8 +532,10 @@ public function getFields()
}
if (!empty($this->params['fields'])) {
$fields = explode(',', $this->params['fields']);
+
return array_values(array_filter(array_map('trim', $fields)));
}
+
return null;
}
@@ -538,11 +554,13 @@ public function getHiddenFields($model)
}
if (!empty($this->params['hidden'])) {
$fields = explode(',', $this->params['hidden']);
+
return array_values(array_filter(array_map('trim', $fields)));
}
$schema = $model->schema();
$columns = $schema->columns();
$whitelist = ['token', 'password', 'passwd'];
+
return array_values(array_intersect($columns, $whitelist));
}
@@ -582,6 +600,7 @@ public function getValidation($model, $associations = [])
$validate[$fieldName] = $validation;
}
}
+
return $validate;
}
@@ -729,6 +748,7 @@ public function getBehaviors($model)
if (!empty($counterCache)) {
$behaviors['CounterCache'] = $counterCache;
}
+
return $behaviors;
}
@@ -759,6 +779,7 @@ public function getCounterCache($model)
$counterCache[] = "'{$otherAlias}' => ['{$field}']";
}
}
+
return $counterCache;
}
@@ -800,6 +821,7 @@ public function bakeEntity($model, array $data = [])
$this->createFile($filename, $out);
$emptyFile = $path . 'Entity' . DS . 'empty';
$this->_deleteEmptyFile($emptyFile);
+
return $out;
}
@@ -857,6 +879,7 @@ public function bakeTable($model, array $data = [])
$emptyFile = $path . 'Table' . DS . 'empty';
$this->_deleteEmptyFile($emptyFile);
+
return $out;
}
@@ -876,6 +899,7 @@ public function listAll()
foreach ($this->_tables as $table) {
$this->_modelNames[] = $this->_camelize($table);
}
+
return $this->_tables;
}
@@ -887,6 +911,7 @@ public function listAll()
public function listUnskipped()
{
$this->listAll();
+
return array_diff($this->_tables, $this->skipTables);
}
@@ -915,15 +940,18 @@ protected function _getAllTables()
$this->err(
'Connections need to implement schemaCollection() to be used with bake.'
);
+
return $this->_stop();
}
$schema = $db->schemaCollection();
$tables = $schema->listTables();
if (empty($tables)) {
$this->err('Your database does not have any tables.');
+
return $this->_stop();
}
sort($tables);
+
return $tables;
}
@@ -940,6 +968,7 @@ public function getTable($name)
if (isset($this->params['table'])) {
return $this->params['table'];
}
+
return Inflector::underscore($name);
}
@@ -1034,6 +1063,7 @@ public function bakeTest($className)
}
$this->Test->plugin = $this->plugin;
$this->Test->connection = $this->connection;
+
return $this->Test->bake('Table', $className);
}
}
diff --git a/src/Shell/Task/PluginTask.php b/src/Shell/Task/PluginTask.php
index 21babc1a2..f36005a62 100644
--- a/src/Shell/Task/PluginTask.php
+++ b/src/Shell/Task/PluginTask.php
@@ -59,13 +59,14 @@ public function initialize()
* Execution method always used for tasks
*
* @param string|null $name The name of the plugin to bake.
- * @return void
+ * @return null|bool
*/
public function main($name = null)
{
if (empty($name)) {
$this->err('You must provide a plugin name in CamelCase format.');
$this->err('To make an "MyExample" plugin, run `cake bake plugin MyExample`.');
+
return false;
}
$plugin = $this->_camelize($name);
@@ -73,6 +74,7 @@ public function main($name = null)
if (is_dir($pluginPath)) {
$this->out(sprintf('Plugin: %s already exists, no action taken', $plugin));
$this->out(sprintf('Path: %s', $pluginPath));
+
return false;
}
if (!$this->bake($plugin)) {
@@ -86,7 +88,7 @@ public function main($name = null)
* Also update the autoloader and the root composer.json file if it can be found
*
* @param string $plugin Name of the plugin in CamelCased format
- * @return bool
+ * @return bool|void
*/
public function bake($plugin)
{
@@ -225,6 +227,7 @@ protected function _modifyAutoloader($plugin, $path)
if (!file_exists($file)) {
$this->out(sprintf('Main composer file %s not found', $file));
+
return false;
}
@@ -245,6 +248,7 @@ protected function _modifyAutoloader($plugin, $path)
if (!$composer) {
$this->error('Could not locate composer. Add composer to your PATH, or use the --composer option.');
+
return false;
}
@@ -260,6 +264,7 @@ protected function _modifyAutoloader($plugin, $path)
} catch (\RuntimeException $e) {
$error = $e->getMessage();
$this->error(sprintf('Could not run `composer dump-autoload`: %s', $error));
+
return false;
}
@@ -302,6 +307,7 @@ public function findPath(array $pathOptions)
if ($max === 1) {
$this->path = $pathOptions[0];
+
return;
}
@@ -358,6 +364,7 @@ public function findComposer()
$paths = explode(PATH_SEPARATOR, $path);
$composer = $this->_searchPath($paths);
}
+
return $composer;
}
@@ -374,10 +381,12 @@ protected function _searchPath($path)
foreach ($composer as $cmd) {
if (is_file($dir . DS . $cmd)) {
$this->_io->verbose('Found composer executable in ' . $dir);
+
return $dir . DS . $cmd;
}
}
}
+
return false;
}
}
diff --git a/src/Shell/Task/SimpleBakeTask.php b/src/Shell/Task/SimpleBakeTask.php
index 5a43e885a..48fc51d39 100644
--- a/src/Shell/Task/SimpleBakeTask.php
+++ b/src/Shell/Task/SimpleBakeTask.php
@@ -65,6 +65,7 @@ public function templateData()
if ($this->plugin) {
$namespace = $this->_pluginNamespace($this->plugin);
}
+
return ['namespace' => $namespace];
}
@@ -72,7 +73,7 @@ public function templateData()
* Execute method
*
* @param string|null $name The name of the object to bake.
- * @return void
+ * @return void|int
*/
public function main($name = null)
{
@@ -102,6 +103,7 @@ public function bake($name)
$this->createFile($filename, $contents);
$emptyFile = $this->getPath() . 'empty';
$this->_deleteEmptyFile($emptyFile);
+
return $contents;
}
@@ -109,7 +111,7 @@ public function bake($name)
* Generate a test case.
*
* @param string $className The class to bake a test for.
- * @return string|bool
+ * @return void|string|bool
*/
public function bakeTest($className)
{
@@ -117,6 +119,7 @@ public function bakeTest($className)
return;
}
$this->Test->plugin = $this->plugin;
+
return $this->Test->bake($this->name(), $className);
}
diff --git a/src/Shell/Task/TemplateTask.php b/src/Shell/Task/TemplateTask.php
index bd6e76d4d..682ba1451 100644
--- a/src/Shell/Task/TemplateTask.php
+++ b/src/Shell/Task/TemplateTask.php
@@ -123,6 +123,7 @@ public function main($name = null, $template = null, $action = null)
foreach ($this->Model->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
+
return true;
}
$name = $this->_getName($name);
@@ -206,6 +207,7 @@ public function getPath()
{
$path = parent::getPath();
$path .= $this->controllerName . DS;
+
return $path;
}
@@ -239,6 +241,7 @@ protected function _methodsToBake()
unset($methods[$i]);
}
}
+
return $methods;
}
@@ -337,7 +340,7 @@ public function bakeActions(array $actions, $vars)
/**
* handle creation of baking a custom action view file
*
- * @return void
+ * @return void|null
*/
public function customAction()
{
@@ -362,6 +365,7 @@ public function customAction()
$looksGood = $this->in('Look okay?', ['y', 'n'], 'y');
if (strtolower($looksGood) === 'y') {
$this->bake($action, ' ');
+
return $this->_stop();
}
$this->out('Bake Aborted.');
@@ -381,12 +385,14 @@ public function bake($action, $content = '')
}
if (empty($content)) {
$this->err("No generated content for '{$action}.ctp', not generating template.");
+
return false;
}
$this->out("\n" . sprintf('Baking `%s` view template file...', $action), 1, Shell::QUIET);
$path = $this->getPath();
$filename = $path . Inflector::underscore($action) . '.ctp';
$this->createFile($filename, $content);
+
return $content;
}
@@ -405,6 +411,7 @@ public function getContent($action, $vars = null)
if (empty($vars['primaryKey'])) {
$this->error('Cannot generate views for models with no primary key');
+
return false;
}
@@ -462,6 +469,7 @@ protected function _filteredAssociations(Table $model)
if (is_null($this->_associationFilter)) {
$this->_associationFilter = new AssociationFilter();
}
+
return $this->_associationFilter->filterAssociations($model);
}
}
diff --git a/src/Shell/Task/TestTask.php b/src/Shell/Task/TestTask.php
index 932e9f472..e65c31b2d 100644
--- a/src/Shell/Task/TestTask.php
+++ b/src/Shell/Task/TestTask.php
@@ -93,7 +93,7 @@ class TestTask extends BakeTask
*
* @param string|null $type Class type.
* @param string|null $name Name.
- * @return void
+ * @return void|array
*/
public function main($type = null, $name = null)
{
@@ -197,6 +197,7 @@ protected function _getClassOptions($namespace)
foreach ($files as $file) {
$classes[] = str_replace('.php', '', $file);
}
+
return $classes;
}
@@ -274,6 +275,7 @@ public function bake($type, $className)
if ($this->createFile($filename, $out)) {
return $out;
}
+
return false;
}
@@ -287,6 +289,7 @@ public function bake($type, $className)
public function typeCanDetectFixtures($type)
{
$type = strtolower($type);
+
return in_array($type, ['controller', 'table']);
}
@@ -318,6 +321,7 @@ public function buildTestSubject($type, $class)
} else {
$instance = new $class();
}
+
return $instance;
}
@@ -340,6 +344,7 @@ public function getRealClassName($type, $class)
if ($suffix && strpos($class, $suffix) === false) {
$class .= $suffix;
}
+
return $namespace . '\\' . $subSpace . '\\' . $class;
}
@@ -352,6 +357,7 @@ public function getRealClassName($type, $class)
public function getSubspacePath($type)
{
$subspace = $this->mapType($type);
+
return str_replace('\\', DS, $subspace);
}
@@ -368,6 +374,7 @@ public function mapType($type)
if (empty($this->classTypes[$type])) {
throw new Exception('Invalid object type.');
}
+
return $this->classTypes[$type];
}
@@ -391,6 +398,7 @@ public function getTestableMethods($className)
}
$out[] = $method->getName();
}
+
return $out;
}
@@ -409,6 +417,7 @@ public function generateFixtureList($subject)
} elseif ($subject instanceof Controller) {
$this->_processController($subject);
}
+
return array_values($this->_fixtures);
}
@@ -488,6 +497,7 @@ protected function _addFixture($name)
public function hasMockClass($type)
{
$type = strtolower($type);
+
return $type === 'controller';
}
@@ -520,16 +530,18 @@ public function generateConstructor($type, $fullClassName)
$construct = "new {$className}(\$registry);";
}
if ($type === 'shell') {
- $pre = "\$this->io = \$this->getMock('Cake\Console\ConsoleIo');";
+ $pre = "\$this->io = \$this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();";
$construct = "new {$className}(\$this->io);";
}
if ($type === 'task') {
- $pre = "\$this->io = \$this->getMock('Cake\Console\ConsoleIo');\n";
- $construct = "\$this->getMock('{$fullClassName}', [], [\$this->io]);";
+ $pre = "\$this->io = \$this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();\n";
+ $construct = "\$this->getMockBuilder('{$fullClassName}')\n";
+ $construct .= " ->setConstructorArgs([\$this->io])\n";
+ $construct .= " ->getMock();";
}
if ($type === 'cell') {
- $pre = "\$this->request = \$this->getMock('Cake\Network\Request');\n";
- $pre .= " \$this->response = \$this->getMock('Cake\Network\Response');";
+ $pre = "\$this->request = \$this->getMockBuilder('Cake\Network\Request')->getMock();\n";
+ $pre .= " \$this->response = \$this->getMockBuilder('Cake\Network\Response')->getMock();";
$construct = "new {$className}(\$this->request, \$this->response);";
}
if ($type === 'shell_helper') {
@@ -537,6 +549,7 @@ public function generateConstructor($type, $fullClassName)
$pre .= " \$this->io = new ConsoleIo(\$this->stub);";
$construct = "new {$className}(\$this->io);";
}
+
return [$pre, $construct, $post];
}
@@ -633,6 +646,7 @@ public function generateUses($type, $fullClassName)
$uses[] = 'Cake\Console\ConsoleIo';
}
$uses[] = $fullClassName;
+
return $uses;
}
@@ -648,6 +662,7 @@ public function getPath()
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . 'tests/' . $dir;
}
+
return $path;
}
@@ -668,6 +683,7 @@ public function testCaseFileName($type, $className)
}
$classTail = substr($className, strlen($namespace) + 1);
$path = $path . $classTail . 'Test.php';
+
return str_replace(['/', '\\'], DS, $path);
}
diff --git a/src/Template/Bake/Element/Controller/add.ctp b/src/Template/Bake/Element/Controller/add.ctp
index 125686834..a0d009db0 100644
--- a/src/Template/Bake/Element/Controller/add.ctp
+++ b/src/Template/Bake/Element/Controller/add.ctp
@@ -27,6 +27,7 @@ $compact = ["'" . $singularName . "'"];
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data);
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) {
$this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.'));
diff --git a/src/Template/Bake/Element/Controller/delete.ctp b/src/Template/Bake/Element/Controller/delete.ctp
index 2026fd62a..41a27e37c 100644
--- a/src/Template/Bake/Element/Controller/delete.ctp
+++ b/src/Template/Bake/Element/Controller/delete.ctp
@@ -30,5 +30,6 @@
} else {
$this->Flash->error(__('The <%= strtolower($singularHumanName) %> could not be deleted. Please, try again.'));
}
+
return $this->redirect(['action' => 'index']);
}
diff --git a/src/Template/Bake/Element/Controller/edit.ctp b/src/Template/Bake/Element/Controller/edit.ctp
index 430e64872..28dde2c59 100644
--- a/src/Template/Bake/Element/Controller/edit.ctp
+++ b/src/Template/Bake/Element/Controller/edit.ctp
@@ -34,6 +34,7 @@ $compact = ["'" . $singularName . "'"];
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data);
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) {
$this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The <%= strtolower($singularHumanName) %> could not be saved. Please, try again.'));
diff --git a/src/Template/Bake/Element/Controller/login.ctp b/src/Template/Bake/Element/Controller/login.ctp
index 36c72f4b8..cf3e0c3f6 100644
--- a/src/Template/Bake/Element/Controller/login.ctp
+++ b/src/Template/Bake/Element/Controller/login.ctp
@@ -25,6 +25,7 @@
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
+
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error(__('Invalid credentials, try again'));
diff --git a/src/Template/Bake/Model/table.ctp b/src/Template/Bake/Model/table.ctp
index f129ea11a..682da9602 100644
--- a/src/Template/Bake/Model/table.ctp
+++ b/src/Template/Bake/Model/table.ctp
@@ -173,6 +173,7 @@ endforeach;
<%- foreach ($rulesChecker as $field => $rule): %>
$rules->add($rules-><%= $rule['name'] %>(['<%= $field %>']<%= !empty($rule['extra']) ? ", '$rule[extra]'" : '' %>));
<%- endforeach; %>
+
return $rules;
}
<% endif; %>
diff --git a/src/Utility/Model/AssociationFilter.php b/src/Utility/Model/AssociationFilter.php
index b983cc9d3..f5356dcff 100644
--- a/src/Utility/Model/AssociationFilter.php
+++ b/src/Utility/Model/AssociationFilter.php
@@ -36,6 +36,7 @@ class AssociationFilter
public function filterHasManyAssociationsAliases(Table $table, array $aliases)
{
$belongsToManyJunctionsAliases = $this->belongsToManyJunctionAliases($table);
+
return array_values(array_diff($aliases, $belongsToManyJunctionsAliases));
}
@@ -50,6 +51,7 @@ public function belongsToManyJunctionAliases(Table $table)
$extractor = function ($val) {
return $val->junction()->alias();
};
+
return array_map($extractor, $table->associations()->type('BelongsToMany'));
}
@@ -106,6 +108,7 @@ public function filterAssociations(Table $model)
}
}
}
+
return $associations;
}
}
diff --git a/src/View/BakeView.php b/src/View/BakeView.php
index 9a358ec2c..1679fd4a5 100644
--- a/src/View/BakeView.php
+++ b/src/View/BakeView.php
@@ -164,6 +164,7 @@ public function render($view = null, $layout = null)
public function dispatchEvent($name, $data = null, $subject = null)
{
$name = preg_replace('/^View\./', 'Bake.', $name);
+
return parent::dispatchEvent($name, $data, $subject);
}
@@ -201,6 +202,7 @@ protected function _evaluate($viewFile, $dataForView)
$content = ob_get_clean();
$unPhp = $this->config('phpTagReplacements');
+
return str_replace(array_values($unPhp), array_keys($unPhp), $content);
}
@@ -228,6 +230,7 @@ protected function _paths($plugin = null, $cached = true)
foreach ($paths as &$path) {
$path .= 'Bake' . DS;
}
+
return $paths;
}
diff --git a/src/View/Helper/BakeHelper.php b/src/View/Helper/BakeHelper.php
index f6d07e3d0..837bad937 100644
--- a/src/View/Helper/BakeHelper.php
+++ b/src/View/Helper/BakeHelper.php
@@ -49,6 +49,7 @@ public function arrayProperty($name, array $value = [], array $options = [])
'name' => $name,
'value' => $value
];
+
return $this->_View->element('array_property', $options);
}
@@ -173,6 +174,7 @@ protected function _filterHasManyAssociationsAliases($table, $aliases)
if (is_null($this->_associationFilter)) {
$this->_associationFilter = new AssociationFilter();
}
+
return $this->_associationFilter->filterHasManyAssociationsAliases($table, $aliases);
}
}
diff --git a/src/View/Helper/DocBlockHelper.php b/src/View/Helper/DocBlockHelper.php
index 0b0c68892..f61e963fe 100644
--- a/src/View/Helper/DocBlockHelper.php
+++ b/src/View/Helper/DocBlockHelper.php
@@ -43,6 +43,7 @@ public function classDescription($className, $classType, array $annotations)
$lines = array_merge(["/**"], (new Collection($lines))->map(function ($line) {
return rtrim(" * {$line}");
})->toArray(), [" */"]);
+
return implode("\n", $lines);
}
@@ -60,6 +61,7 @@ public function associatedEntityTypeToHintType($type, Association $association)
) {
return $type . '[]';
}
+
return $type;
}
@@ -92,6 +94,7 @@ public function buildEntityPropertyHintTypeMap(array $propertySchema)
$properties[$property] = $this->columnTypeToHintType($info['type']);
}
}
+
return $properties;
}
@@ -133,6 +136,7 @@ public function buildEntityAssociationHintTypeMap(array $propertySchema)
}
}
}
+
return $properties;
}
@@ -193,6 +197,7 @@ public function propertyHints(array $properties)
$type = $type ? $type . ' ' : '';
$lines[] = "@property {$type}\${$property}";
}
+
return $lines;
}
@@ -218,6 +223,7 @@ protected function _insertAfter(array $target, $key, $value)
} else {
$target += (array)$value;
}
+
return $target;
}
}
diff --git a/tests/TestCase/Shell/BakeShellTest.php b/tests/TestCase/Shell/BakeShellTest.php
index d3f0a9678..180ab78c5 100644
--- a/tests/TestCase/Shell/BakeShellTest.php
+++ b/tests/TestCase/Shell/BakeShellTest.php
@@ -55,11 +55,11 @@ public function setUp()
$this->out = new ConsoleOutput();
$this->io = new ConsoleIo($this->out);
- $this->Shell = $this->getMock(
- 'Bake\Shell\BakeShell',
- ['in', 'createFile', '_stop'],
- [$this->io]
- );
+ $this->Shell = $this->getMockBuilder('Bake\Shell\BakeShell')
+ ->setMethods(['in', 'createFile', '_stop'])
+ ->setConstructorArgs([$this->io])
+ ->getMock();
+
Configure::write('App.namespace', 'Bake\Test\App');
}
@@ -81,9 +81,9 @@ public function tearDown()
*/
public function testAllWithModelName()
{
- $this->Shell->Model = $this->getMock('Bake\Shell\Task\ModelTask');
- $this->Shell->Controller = $this->getMock('Bake\Shell\Task\ControllerTask');
- $this->Shell->Template = $this->getMock('Bake\Shell\Task\TemplateTask');
+ $this->Shell->Model = $this->getMockBuilder('Bake\Shell\Task\ModelTask')->getMock();
+ $this->Shell->Controller = $this->getMockBuilder('Bake\Shell\Task\ControllerTask')->getMock();
+ $this->Shell->Template = $this->getMockBuilder('Bake\Shell\Task\TemplateTask')->getMock();
$this->Shell->Model->expects($this->once())
->method('main')
diff --git a/tests/TestCase/Shell/Task/BakeTemplateTaskTest.php b/tests/TestCase/Shell/Task/BakeTemplateTaskTest.php
index 591114dd4..96a2e4511 100644
--- a/tests/TestCase/Shell/Task/BakeTemplateTaskTest.php
+++ b/tests/TestCase/Shell/Task/BakeTemplateTaskTest.php
@@ -36,13 +36,15 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'BakeTemplate' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\BakeTemplateTask',
- ['in', 'err', 'createFile', '_stop', 'clear'],
- [$io]
- );
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\BakeTemplateTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', 'clear'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+ ;
}
/**
diff --git a/tests/TestCase/Shell/Task/CellTaskTest.php b/tests/TestCase/Shell/Task/CellTaskTest.php
index 5af38e46f..1cd931d07 100644
--- a/tests/TestCase/Shell/Task/CellTaskTest.php
+++ b/tests/TestCase/Shell/Task/CellTaskTest.php
@@ -38,18 +38,19 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Cell' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\CellTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\CellTask',
- ['in', 'err', 'createFile', '_stop'],
- [$io]
- );
- $this->Task->Test = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- [],
- [$io]
- );
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->initialize();
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/TestCase/Shell/Task/ControllerTaskTest.php b/tests/TestCase/Shell/Task/ControllerTaskTest.php
index f3fafaf0f..ed1bf3e88 100644
--- a/tests/TestCase/Shell/Task/ControllerTaskTest.php
+++ b/tests/TestCase/Shell/Task/ControllerTaskTest.php
@@ -52,27 +52,27 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Controller' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\ControllerTask',
- ['in', 'out', 'err', 'hr', 'createFile', '_stop'],
- [$io]
- );
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\ControllerTask')
+ ->setMethods(['in', 'out', 'err', 'hr', 'createFile', '_stop'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
$this->Task->name = 'Controller';
$this->Task->connection = 'test';
$this->Task->BakeTemplate = new BakeTemplateTask($io);
- $this->Task->Model = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'out', 'err', 'createFile', '_stop'],
- [$io]
- );
- $this->Task->Test = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- [],
- [$io]
- );
+ $this->Task->Model = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'out', 'err', 'createFile', '_stop'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
TableRegistry::get('BakeArticles', [
'className' => __NAMESPACE__ . '\BakeArticlesTable'
diff --git a/tests/TestCase/Shell/Task/FixtureTaskTest.php b/tests/TestCase/Shell/Task/FixtureTaskTest.php
index 93274a686..f04e2c610 100644
--- a/tests/TestCase/Shell/Task/FixtureTaskTest.php
+++ b/tests/TestCase/Shell/Task/FixtureTaskTest.php
@@ -52,18 +52,18 @@ class FixtureTaskTest extends TestCase
public function setUp()
{
parent::setUp();
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\FixtureTask',
- ['in', 'err', 'createFile', '_stop', 'clear'],
- [$io]
- );
- $this->Task->Model = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listUnskipped'],
- [$io]
- );
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\FixtureTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', 'clear'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+ $this->Task->Model = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listUnskipped'])
+ ->setConstructorArgs([$io])
+ ->getMock();
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->interactive = false;
$this->Task->BakeTemplate->initialize();
diff --git a/tests/TestCase/Shell/Task/MailerTaskTest.php b/tests/TestCase/Shell/Task/MailerTaskTest.php
index a2af6a7d5..08dd884e3 100644
--- a/tests/TestCase/Shell/Task/MailerTaskTest.php
+++ b/tests/TestCase/Shell/Task/MailerTaskTest.php
@@ -38,18 +38,20 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Mailer' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\MailerTask',
- ['in', 'err', 'createFile', '_stop'],
- [$io]
- );
- $this->Task->Test = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- [],
- [$io]
- );
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\MailerTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
+
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->initialize();
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/TestCase/Shell/Task/ModelTaskAssociationDetectionTest.php b/tests/TestCase/Shell/Task/ModelTaskAssociationDetectionTest.php
index c209adf41..ed2ae8b42 100644
--- a/tests/TestCase/Shell/Task/ModelTaskAssociationDetectionTest.php
+++ b/tests/TestCase/Shell/Task/ModelTaskAssociationDetectionTest.php
@@ -56,13 +56,15 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Model' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', '_checkUnitTest'])
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'err', 'createFile', '_stop', '_checkUnitTest'],
- [$io]
- );
$this->Task->connection = 'default';
$this->_setupOtherMocks();
TableRegistry::clear();
@@ -75,13 +77,15 @@ public function setUp()
*/
protected function _useMockedOut()
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'])
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'],
- [$io]
- );
$this->_setupOtherMocks();
}
@@ -92,10 +96,16 @@ protected function _useMockedOut()
*/
protected function _setupOtherMocks()
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task->Fixture = $this->getMock('Bake\Shell\Task\FixtureTask', [], [$io]);
- $this->Task->Test = $this->getMock('Bake\Shell\Task\FixtureTask', [], [$io]);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task->Fixture = $this->getMockBuilder('Bake\Shell\Task\FixtureTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\FixtureTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/TestCase/Shell/Task/ModelTaskTest.php b/tests/TestCase/Shell/Task/ModelTaskTest.php
index b950c42c1..5b2afa412 100644
--- a/tests/TestCase/Shell/Task/ModelTaskTest.php
+++ b/tests/TestCase/Shell/Task/ModelTaskTest.php
@@ -70,13 +70,15 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Model' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', '_checkUnitTest'])
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'err', 'createFile', '_stop', '_checkUnitTest'],
- [$io]
- );
$this->Task->connection = 'test';
$this->_setupOtherMocks();
TableRegistry::clear();
@@ -89,13 +91,15 @@ public function setUp()
*/
protected function _useMockedOut()
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setMethods(['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'])
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\ModelTask',
- ['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'],
- [$io]
- );
$this->_setupOtherMocks();
}
@@ -106,10 +110,16 @@ protected function _useMockedOut()
*/
protected function _setupOtherMocks()
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task->Fixture = $this->getMock('Bake\Shell\Task\FixtureTask', [], [$io]);
- $this->Task->Test = $this->getMock('Bake\Shell\Task\FixtureTask', [], [$io]);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task->Fixture = $this->getMockBuilder('Bake\Shell\Task\FixtureTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\FixtureTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/TestCase/Shell/Task/PluginTaskTest.php b/tests/TestCase/Shell/Task/PluginTaskTest.php
index b73af5fd3..f80f78681 100644
--- a/tests/TestCase/Shell/Task/PluginTaskTest.php
+++ b/tests/TestCase/Shell/Task/PluginTaskTest.php
@@ -48,13 +48,14 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Plugin' . DS;
- $this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\PluginTask',
- ['in', 'err', '_stop', 'clear', 'callProcess', '_rootComposerFilePath', 'findComposer'],
- [$this->io]
- );
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\PluginTask')
+ ->setMethods(['in', 'err', '_stop', 'clear', 'callProcess', '_rootComposerFilePath', 'findComposer'])
+ ->setConstructorArgs([$this->io])
+ ->getMock();
$this->Task->BakeTemplate = new BakeTemplateTask($this->io);
$this->Task->BakeTemplate->interactive = false;
@@ -194,11 +195,11 @@ public function testFindPathNonExistent()
array_unshift($paths, '/fake/path');
$paths[] = '/fake/path2';
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\PluginTask',
- ['in', 'out', 'err', '_stop'],
- [$this->io]
- );
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\PluginTask')
+ ->setMethods(['in', 'out', 'err', '_stop'])
+ ->setConstructorArgs([$this->io])
+ ->getMock();
+
$this->Task->path = TMP . 'tests' . DS;
$this->Task->method('findPath')
diff --git a/tests/TestCase/Shell/Task/SimpleBakeTaskTest.php b/tests/TestCase/Shell/Task/SimpleBakeTaskTest.php
index 99f2e7a6b..229dbb963 100644
--- a/tests/TestCase/Shell/Task/SimpleBakeTaskTest.php
+++ b/tests/TestCase/Shell/Task/SimpleBakeTaskTest.php
@@ -38,18 +38,19 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Simple' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\SimpleBakeTask',
- ['in', 'err', 'createFile', '_stop', 'name', 'template', 'fileName'],
- [$io]
- );
- $this->Task->Test = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- [],
- [$io]
- );
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\SimpleBakeTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', 'name', 'template', 'fileName'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
+
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->initialize();
$this->Task->BakeTemplate->interactive = false;
@@ -210,7 +211,9 @@ public function subclassProvider()
*/
public function testImplementations($class)
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
$task = new $class($io);
$this->assertInternalType('string', $task->name());
$this->assertInternalType('string', $task->fileName('Example'));
diff --git a/tests/TestCase/Shell/Task/TaskTaskTest.php b/tests/TestCase/Shell/Task/TaskTaskTest.php
index fca16744f..ffbc587eb 100644
--- a/tests/TestCase/Shell/Task/TaskTaskTest.php
+++ b/tests/TestCase/Shell/Task/TaskTaskTest.php
@@ -38,18 +38,19 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Shell' . DS . 'Task' . DS;
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
-
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\TaskTask',
- ['in', 'err', 'createFile', '_stop'],
- [$io]
- );
- $this->Task->Test = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- [],
- [$io]
- );
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\TaskTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop'])
+ ->setConstructorArgs([$io])
+ ->getMock();
+
+ $this->Task->Test = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
+
$this->Task->BakeTemplate = new BakeTemplateTask($io);
$this->Task->BakeTemplate->initialize();
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/TestCase/Shell/Task/TemplateTaskTest.php b/tests/TestCase/Shell/Task/TemplateTaskTest.php
index 50a605d1c..8df82d416 100644
--- a/tests/TestCase/Shell/Task/TemplateTaskTest.php
+++ b/tests/TestCase/Shell/Task/TemplateTaskTest.php
@@ -71,15 +71,19 @@ public function setUp()
*/
protected function _setupTask($methods)
{
- $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\TemplateTask')
+ ->setMethods($methods)
+ ->setConstructorArgs([$io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\TemplateTask',
- $methods,
- [$io]
- );
$this->Task->BakeTemplate = new BakeTemplateTask($io);
- $this->Task->Model = $this->getMock('Bake\Shell\Task\ModelTask', [], [$io]);
+ $this->Task->Model = $this->getMockBuilder('Bake\Shell\Task\ModelTask')
+ ->setConstructorArgs([$io])
+ ->getMock();
}
/**
diff --git a/tests/TestCase/Shell/Task/TestTaskTest.php b/tests/TestCase/Shell/Task/TestTaskTest.php
index 2e3299a1d..800f1c4b4 100644
--- a/tests/TestCase/Shell/Task/TestTaskTest.php
+++ b/tests/TestCase/Shell/Task/TestTaskTest.php
@@ -63,13 +63,15 @@ public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Test' . DS;
- $this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
+ $this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->Task = $this->getMockBuilder('Bake\Shell\Task\TestTask')
+ ->setMethods(['in', 'err', 'createFile', '_stop', 'isLoadableClass'])
+ ->setConstructorArgs([$this->io])
+ ->getMock();
- $this->Task = $this->getMock(
- 'Bake\Shell\Task\TestTask',
- ['in', 'err', 'createFile', '_stop', 'isLoadableClass'],
- [$this->io]
- );
$this->Task->name = 'Test';
$this->Task->BakeTemplate = new BakeTemplateTask($this->io);
$this->Task->BakeTemplate->interactive = false;
diff --git a/tests/comparisons/Controller/testBakeActions.php b/tests/comparisons/Controller/testBakeActions.php
index d48c75d25..9e196ea8d 100644
--- a/tests/comparisons/Controller/testBakeActions.php
+++ b/tests/comparisons/Controller/testBakeActions.php
@@ -72,6 +72,7 @@ public function add()
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -99,6 +100,7 @@ public function edit($id = null)
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -126,6 +128,7 @@ public function delete($id = null)
} else {
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
}
+
return $this->redirect(['action' => 'index']);
}
}
diff --git a/tests/comparisons/Controller/testBakeActionsContent.php b/tests/comparisons/Controller/testBakeActionsContent.php
index b7b83725d..77b9666ab 100644
--- a/tests/comparisons/Controller/testBakeActionsContent.php
+++ b/tests/comparisons/Controller/testBakeActionsContent.php
@@ -56,6 +56,7 @@ public function add()
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -83,6 +84,7 @@ public function edit($id = null)
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -110,6 +112,7 @@ public function delete($id = null)
} else {
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
}
+
return $this->redirect(['action' => 'index']);
}
}
diff --git a/tests/comparisons/Controller/testBakeWithPlugin.php b/tests/comparisons/Controller/testBakeWithPlugin.php
index dd7986de0..9ad4a22cc 100644
--- a/tests/comparisons/Controller/testBakeWithPlugin.php
+++ b/tests/comparisons/Controller/testBakeWithPlugin.php
@@ -56,6 +56,7 @@ public function add()
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -83,6 +84,7 @@ public function edit($id = null)
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success(__('The bake article has been saved.'));
+
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
@@ -110,6 +112,7 @@ public function delete($id = null)
} else {
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
}
+
return $this->redirect(['action' => 'index']);
}
}
diff --git a/tests/comparisons/Model/testBakeAssociationDetectionCategoriesProductsTable.php b/tests/comparisons/Model/testBakeAssociationDetectionCategoriesProductsTable.php
index 1a3dfb989..4905fe0f5 100644
--- a/tests/comparisons/Model/testBakeAssociationDetectionCategoriesProductsTable.php
+++ b/tests/comparisons/Model/testBakeAssociationDetectionCategoriesProductsTable.php
@@ -58,6 +58,7 @@ public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['category_id'], 'Categories'));
$rules->add($rules->existsIn(['product_id'], 'Products'));
+
return $rules;
}
}
diff --git a/tests/comparisons/Model/testBakeAssociationDetectionProductVersionsTable.php b/tests/comparisons/Model/testBakeAssociationDetectionProductVersionsTable.php
index a3773a5ad..3bf128ff7 100644
--- a/tests/comparisons/Model/testBakeAssociationDetectionProductVersionsTable.php
+++ b/tests/comparisons/Model/testBakeAssociationDetectionProductVersionsTable.php
@@ -72,6 +72,7 @@ public function validationDefault(Validator $validator)
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['product_id'], 'Products'));
+
return $rules;
}
}
diff --git a/tests/comparisons/Model/testBakeWithRules.php b/tests/comparisons/Model/testBakeWithRules.php
index 21fc382ae..03561f03e 100644
--- a/tests/comparisons/Model/testBakeWithRules.php
+++ b/tests/comparisons/Model/testBakeWithRules.php
@@ -45,6 +45,7 @@ public function buildRules(RulesChecker $rules)
$rules->add($rules->isUnique(['username']));
$rules->add($rules->existsIn(['country_id'], 'Countries'));
$rules->add($rules->existsIn(['site_id'], 'Sites'));
+
return $rules;
}
diff --git a/tests/comparisons/Test/testBakeCellTest.php b/tests/comparisons/Test/testBakeCellTest.php
index ee49fd089..8bfab751c 100644
--- a/tests/comparisons/Test/testBakeCellTest.php
+++ b/tests/comparisons/Test/testBakeCellTest.php
@@ -39,8 +39,8 @@ class ArticlesCellTest extends TestCase
public function setUp()
{
parent::setUp();
- $this->request = $this->getMock('Cake\Network\Request');
- $this->response = $this->getMock('Cake\Network\Response');
+ $this->request = $this->getMockBuilder('Cake\Network\Request')->getMock();
+ $this->response = $this->getMockBuilder('Cake\Network\Response')->getMock();
$this->Articles = new ArticlesCell($this->request, $this->response);
}
diff --git a/tests/comparisons/Test/testBakeShellTaskTest.php b/tests/comparisons/Test/testBakeShellTaskTest.php
index d788001ce..2edbea755 100644
--- a/tests/comparisons/Test/testBakeShellTaskTest.php
+++ b/tests/comparisons/Test/testBakeShellTaskTest.php
@@ -32,9 +32,11 @@ class ArticlesTaskTest extends TestCase
public function setUp()
{
parent::setUp();
- $this->io = $this->getMock('Cake\Console\ConsoleIo');
+ $this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();
- $this->Articles = $this->getMock('App\Shell\Task\ArticlesTask', [], [$this->io]);
+ $this->Articles = $this->getMockBuilder('App\Shell\Task\ArticlesTask')
+ ->setConstructorArgs([$this->io])
+ ->getMock();
}
/**
diff --git a/tests/comparisons/Test/testBakeShellTest.php b/tests/comparisons/Test/testBakeShellTest.php
index e66d8a195..655f9c25d 100644
--- a/tests/comparisons/Test/testBakeShellTest.php
+++ b/tests/comparisons/Test/testBakeShellTest.php
@@ -32,7 +32,7 @@ class ArticlesShellTest extends TestCase
public function setUp()
{
parent::setUp();
- $this->io = $this->getMock('Cake\Console\ConsoleIo');
+ $this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();
$this->Articles = new ArticlesShell($this->io);
}