Replaces deprecated paginate() calls in controller bake templates.

Fixes #3895.
This commit is contained in:
Phally 2013-07-20 16:59:39 +02:00
parent 1402796047
commit 6d6be87f8f
3 changed files with 10 additions and 9 deletions

View file

@ -370,10 +370,11 @@ class ControllerTask extends BakeTask {
* @return array Components the user wants to use. * @return array Components the user wants to use.
*/ */
public function doComponents() { public function doComponents() {
return $this->_doPropertyChoices( $components = array('Paginator');
__d('cake_console', "Would you like this controller to use any components?"), 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'") __d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
); ));
} }
/** /**

View file

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

View file

@ -224,7 +224,7 @@ class ControllerTaskTest extends CakeTestCase {
public function testDoComponentsNo() { public function testDoComponentsNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); $this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doComponents(); $result = $this->Task->doComponents();
$this->assertSame(array(), $result); $this->assertSame(array('Paginator'), $result);
} }
/** /**
@ -237,7 +237,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security ')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security '));
$result = $this->Task->doComponents(); $result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security'); $expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -251,7 +251,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , ')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , '));
$result = $this->Task->doComponents(); $result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security'); $expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -350,7 +350,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains('function index() {', $result); $this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $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('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
@ -388,7 +388,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains('function index() {', $result); $this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $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('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);