Skip to content

Commit

Permalink
Replaces deprecated paginate() calls in controller bake templates.
Browse files Browse the repository at this point in the history
Fixes #3895.
  • Loading branch information
Phally committed Jul 20, 2013
1 parent 1402796 commit 6d6be87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -370,10 +370,11 @@ public function doHelpers() {
* @return array Components the user wants to use.
*/
public function doComponents() {
return $this->_doPropertyChoices(
__d('cake_console', "Would you like this controller to use any components?"),
$components = array('Paginator');
return array_merge($components, $this->_doPropertyChoices(
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"),
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
);
));
}

/**
Expand Down
Expand Up @@ -26,7 +26,7 @@
*/
public function <?php echo $admin ?>index() {
$this-><?php echo $currentModelName ?>->recursive = 0;
$this->set('<?php echo $pluralName ?>', $this->paginate());
$this->set('<?php echo $pluralName ?>', $this->Paginator->paginate());
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
Expand Up @@ -224,7 +224,7 @@ public function testDoHelpersTrailingCommas() {
public function testDoComponentsNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doComponents();
$this->assertSame(array(), $result);
$this->assertSame(array('Paginator'), $result);
}

/**
Expand All @@ -237,7 +237,7 @@ public function testDoComponentsTrailingSpaces() {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security '));

$result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security');
$expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}

Expand All @@ -251,7 +251,7 @@ public function testDoComponentsTrailingCommas() {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , '));

$result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security');
$expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -350,7 +350,7 @@ public function testBakeActionsUsingSessions() {

$this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);

$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
Expand Down Expand Up @@ -388,7 +388,7 @@ public function testBakeActionsWithNoSessions() {

$this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);

$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
Expand Down

0 comments on commit 6d6be87

Please sign in to comment.