mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 15:39:53 +00:00
Fix most coding standards issues in Test/Console
This commit is contained in:
parent
fdcb3dc34f
commit
ed1d34accc
15 changed files with 54 additions and 50 deletions
|
@ -28,7 +28,9 @@ App::uses('Controller', 'Controller');
|
||||||
|
|
||||||
if (!class_exists('UsersController')) {
|
if (!class_exists('UsersController')) {
|
||||||
class UsersController extends Controller {
|
class UsersController extends Controller {
|
||||||
|
|
||||||
public $name = 'Users';
|
public $name = 'Users';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,17 @@ App::uses('Shell', 'Console');
|
||||||
|
|
||||||
|
|
||||||
class TestStringOutput extends ConsoleOutput {
|
class TestStringOutput extends ConsoleOutput {
|
||||||
|
|
||||||
public $output = '';
|
public $output = '';
|
||||||
|
|
||||||
protected function _write($message) {
|
protected function _write($message) {
|
||||||
$this->output .= $message;
|
$this->output .= $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommandListShellTest extends CakeTestCase {
|
class CommandListShellTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
|
@ -85,7 +88,6 @@ class CommandListShellTest extends CakeTestCase {
|
||||||
$expected = "/welcome \[.*TestPluginTwo.*\]/";
|
$expected = "/welcome \[.*TestPluginTwo.*\]/";
|
||||||
$this->assertRegExp($expected, $output);
|
$this->assertRegExp($expected, $output);
|
||||||
|
|
||||||
|
|
||||||
$expected = "/acl \[.*CORE.*\]/";
|
$expected = "/acl \[.*CORE.*\]/";
|
||||||
$this->assertRegExp($expected, $output);
|
$this->assertRegExp($expected, $output);
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,13 @@ if (!$imported) {
|
||||||
define('ARTICLE_MODEL_CREATED', true);
|
define('ARTICLE_MODEL_CREATED', true);
|
||||||
|
|
||||||
class BakeArticle extends Model {
|
class BakeArticle extends Model {
|
||||||
|
|
||||||
public $name = 'BakeArticle';
|
public $name = 'BakeArticle';
|
||||||
|
|
||||||
public $hasMany = array('BakeComment');
|
public $hasMany = array('BakeComment');
|
||||||
|
|
||||||
public $hasAndBelongsToMany = array('BakeTag');
|
public $hasAndBelongsToMany = array('BakeTag');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +555,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static function nameVariations() {
|
public static function nameVariations() {
|
||||||
return array(
|
return array(
|
||||||
array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
|
array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
|
||||||
);
|
);
|
||||||
|
|
|
@ -358,7 +358,6 @@ class ExtractTaskTest extends CakeTestCase {
|
||||||
$this->assertRegExp($pattern, $result);
|
$this->assertRegExp($pattern, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the extract shell can obtain validation messages from models inside a specific plugin
|
* Test that the extract shell can obtain validation messages from models inside a specific plugin
|
||||||
*
|
*
|
||||||
|
|
|
@ -861,7 +861,7 @@ STRINGEND;
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static function nameVariations() {
|
public static function nameVariations() {
|
||||||
return array(
|
return array(
|
||||||
array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
|
array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,6 +99,7 @@ class TestTaskArticle extends Model {
|
||||||
*/
|
*/
|
||||||
protected function _innerMethod() {
|
protected function _innerMethod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +539,6 @@ class TestTaskTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that mock class generation works for the appropriate classes
|
* Test that mock class generation works for the appropriate classes
|
||||||
*
|
*
|
||||||
|
|
|
@ -119,6 +119,7 @@ class ViewTaskCommentsController extends Controller {
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,6 +192,7 @@ class ViewTaskArticlesController extends Controller {
|
||||||
*/
|
*/
|
||||||
public function admin_delete() {
|
public function admin_delete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -607,7 +609,6 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->any())->method('in')
|
$this->Task->expects($this->any())->method('in')
|
||||||
->will($this->onConsecutiveCalls('y', 'y', 'n'));
|
->will($this->onConsecutiveCalls('y', 'y', 'n'));
|
||||||
|
|
||||||
|
|
||||||
$this->Task->expects($this->at(3))->method('createFile')
|
$this->Task->expects($this->at(3))->method('createFile')
|
||||||
->with(
|
->with(
|
||||||
TMP . 'ViewTaskComments' . DS . 'index.ctp',
|
TMP . 'ViewTaskComments' . DS . 'index.ctp',
|
||||||
|
|
|
@ -29,11 +29,11 @@ class TestTestShell extends TestShell {
|
||||||
public function mapFileToCategory($file) {
|
public function mapFileToCategory($file) {
|
||||||
return $this->_mapFileToCategory($file);
|
return $this->_mapFileToCategory($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestShellTest extends CakeTestCase {
|
class TestShellTest extends CakeTestCase {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp test case
|
* setUp test case
|
||||||
*
|
*
|
||||||
|
@ -111,7 +111,6 @@ class TestShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$return = $this->Shell->mapFileToCategory(APP . 'My/File/Is/Here.php');
|
$return = $this->Shell->mapFileToCategory(APP . 'My/File/Is/Here.php');
|
||||||
$this->assertSame('app', $return);
|
$this->assertSame('app', $return);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +141,6 @@ class TestShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$return = $this->Shell->mapFileToCategory(dirname(CAKE) . 'plugins/awesome/Controller/ExampleController.php');
|
$return = $this->Shell->mapFileToCategory(dirname(CAKE) . 'plugins/awesome/Controller/ExampleController.php');
|
||||||
$this->assertSame('awesome', $return);
|
$this->assertSame('awesome', $return);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +209,6 @@ class TestShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$return = $this->Shell->mapFileToCategory(APP . 'Test/Case/My/File/Is/HereTest.php');
|
$return = $this->Shell->mapFileToCategory(APP . 'Test/Case/My/File/Is/HereTest.php');
|
||||||
$this->assertSame('app', $return);
|
$this->assertSame('app', $return);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,7 +239,6 @@ class TestShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$return = $this->Shell->mapFileToCategory(dirname(CAKE) . 'plugins/awesome/Test/Case/Controller/ExampleControllerTest.php');
|
$return = $this->Shell->mapFileToCategory(dirname(CAKE) . 'plugins/awesome/Test/Case/Controller/ExampleControllerTest.php');
|
||||||
$this->assertSame('awesome', $return);
|
$this->assertSame('awesome', $return);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,6 @@ class TestShellDispatcher extends ShellDispatcher {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +95,7 @@ class TestShellDispatcher extends ShellDispatcher {
|
||||||
}
|
}
|
||||||
return parent::_getShell($shell);
|
return parent::_getShell($shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,20 +55,18 @@ class ShellTestShell extends Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function do_something() {
|
public function do_something() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _secret() {
|
protected function _secret() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function no_access() {
|
protected function no_access() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeVars($properties, $class, $normalize = true) {
|
public function mergeVars($properties, $class, $normalize = true) {
|
||||||
return $this->_mergeVars($properties, $class, $normalize);
|
return $this->_mergeVars($properties, $class, $normalize);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,8 +75,11 @@ class ShellTestShell extends Shell {
|
||||||
* @package Cake.Test.Case.Console.Command
|
* @package Cake.Test.Case.Console.Command
|
||||||
*/
|
*/
|
||||||
class TestMergeShell extends Shell {
|
class TestMergeShell extends Shell {
|
||||||
|
|
||||||
public $tasks = array('DbConfig', 'Fixture');
|
public $tasks = array('DbConfig', 'Fixture');
|
||||||
|
|
||||||
public $uses = array('Comment');
|
public $uses = array('Comment');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,7 +468,7 @@ class ShellTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function test__getArgAndParamReferences() {
|
public function testMagicGetArgAndParamReferences() {
|
||||||
$this->Shell->tasks = array('TestApple');
|
$this->Shell->tasks = array('TestApple');
|
||||||
$this->Shell->args = array('one');
|
$this->Shell->args = array('one');
|
||||||
$this->Shell->params = array('help' => false);
|
$this->Shell->params = array('help' => false);
|
||||||
|
@ -566,7 +567,6 @@ class ShellTest extends CakeTestCase {
|
||||||
->method('read')
|
->method('read')
|
||||||
->will($this->returnValue('y'));
|
->will($this->returnValue('y'));
|
||||||
|
|
||||||
|
|
||||||
$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n";
|
$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n";
|
||||||
$result = $this->Shell->createFile($file, $contents);
|
$result = $this->Shell->createFile($file, $contents);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -659,7 +659,6 @@ class ShellTest extends CakeTestCase {
|
||||||
->method('read')
|
->method('read')
|
||||||
->will($this->returnValue('y'));
|
->will($this->returnValue('y'));
|
||||||
|
|
||||||
|
|
||||||
$contents = "<?php\r\necho 'yet another test';\r\n\$te = 'st';\r\n";
|
$contents = "<?php\r\necho 'yet another test';\r\n\$te = 'st';\r\n";
|
||||||
$result = $this->Shell->createFile($file, $contents);
|
$result = $this->Shell->createFile($file, $contents);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -774,7 +773,6 @@ class ShellTest extends CakeTestCase {
|
||||||
->will($this->returnValue($Parser));
|
->will($this->returnValue($Parser));
|
||||||
$Mock->expects($this->once())->method('out');
|
$Mock->expects($this->once())->method('out');
|
||||||
|
|
||||||
|
|
||||||
$result = $Mock->runCommand('idontexist', array());
|
$result = $Mock->runCommand('idontexist', array());
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
}
|
}
|
||||||
|
@ -869,4 +867,5 @@ TEXT;
|
||||||
|
|
||||||
$this->assertEquals('plugin.test', $parser->command());
|
$this->assertEquals('plugin.test', $parser->command());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ App::uses('TaskCollection', 'Console');
|
||||||
App::uses('Shell', 'Console');
|
App::uses('Shell', 'Console');
|
||||||
|
|
||||||
class TaskCollectionTest extends CakeTestCase {
|
class TaskCollectionTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp
|
* setUp
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue