Skip to content

Commit

Permalink
Don't always add Form and Paginator.
Browse files Browse the repository at this point in the history
They are lazy loaded as needed. We don't need to force them into the
property lists.
  • Loading branch information
markstory committed Mar 21, 2014
1 parent 116062b commit 19c7ab7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
6 changes: 0 additions & 6 deletions src/Console/Command/Task/ControllerTask.php
Expand Up @@ -232,9 +232,6 @@ public function getComponents() {
$components = explode(',', $this->params['components']);
$components = array_values(array_filter(array_map('trim', $components)));
}
if (!in_array('Paginator', $components)) {
$components[] = 'Paginator';
}
return $components;
}

Expand All @@ -249,9 +246,6 @@ public function getHelpers() {
$helpers = explode(',', $this->params['helpers']);
$helpers = array_values(array_filter(array_map('trim', $helpers)));
}
if (count($helpers) && !in_array('Form', $helpers)) {
$helpers[] = 'Form';
}
return $helpers;
}

Expand Down
16 changes: 4 additions & 12 deletions tests/TestCase/Console/Command/Task/ControllerTaskTest.php
Expand Up @@ -121,15 +121,11 @@ public function testListAll() {
*/
public function testGetComponents() {
$result = $this->Task->getComponents();
$this->assertSame(['Paginator'], $result);
$this->assertSame([], $result);

$this->Task->params['components'] = ' , Security, , Csrf';
$result = $this->Task->getComponents();
$this->assertSame(['Security', 'Csrf', 'Paginator'], $result);

$this->Task->params['components'] = ' Paginator , Security, , Csrf';
$result = $this->Task->getComponents();
$this->assertSame(['Paginator', 'Security', 'Csrf'], $result);
$this->assertSame(['Security', 'Csrf'], $result);
}

/**
Expand All @@ -143,11 +139,7 @@ public function testGetHelpers() {

$this->Task->params['helpers'] = ' , Session , , Number';
$result = $this->Task->getHelpers();
$this->assertSame(['Session', 'Number', 'Form'], $result);

$this->Task->params['helpers'] = ' Session , Number , , Form';
$result = $this->Task->getHelpers();
$this->assertSame(['Session', 'Number', 'Form'], $result);
$this->assertSame(['Session', 'Number'], $result);
}

/**
Expand Down Expand Up @@ -305,7 +297,7 @@ public function testExecuteIntoAll() {
->method('createFile')
->with($filename, $this->logicalAnd(
$this->stringContains('class BakeArticlesController'),
$this->stringContains("\$helpers = ['Time', 'Text', 'Form']")
$this->stringContains("\$helpers = ['Time', 'Text']")
))
->will($this->returnValue(true));

Expand Down
5 changes: 2 additions & 3 deletions tests/bake_compare/Controller/NoActions.ctp
Expand Up @@ -9,7 +9,6 @@ use App\Controller\AppController;
* @property App\Model\Table\BakeArticlesTable $BakeArticles
* @property CsrfComponent $Csrf
* @property AuthComponent $Auth
* @property PaginatorComponent $Paginator
*/
class BakeArticlesController extends AppController {

Expand All @@ -18,13 +17,13 @@ class BakeArticlesController extends AppController {
*
* @var array
*/
public $helpers = ['Html', 'Time', 'Form'];
public $helpers = ['Html', 'Time'];

/**
* Components
*
* @var array
*/
public $components = ['Csrf', 'Auth', 'Paginator'];
public $components = ['Csrf', 'Auth'];

}

0 comments on commit 19c7ab7

Please sign in to comment.