mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Updating PaginatorHelper and its test cases to use the request object.
This commit is contained in:
parent
c5dfd128fb
commit
3983bf318d
2 changed files with 118 additions and 115 deletions
|
@ -107,7 +107,7 @@ class PaginatorHelper extends AppHelper {
|
|||
* @return void
|
||||
*/
|
||||
public function beforeRender() {
|
||||
$this->options['url'] = array_merge($this->params['pass'], $this->params['named']);
|
||||
$this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']);
|
||||
|
||||
parent::beforeRender();
|
||||
}
|
||||
|
@ -122,10 +122,10 @@ class PaginatorHelper extends AppHelper {
|
|||
if (empty($model)) {
|
||||
$model = $this->defaultModel();
|
||||
}
|
||||
if (!isset($this->params['paging']) || empty($this->params['paging'][$model])) {
|
||||
if (!isset($this->request->params['paging']) || empty($this->request->params['paging'][$model])) {
|
||||
return null;
|
||||
}
|
||||
return $this->params['paging'][$model];
|
||||
return $this->request->params['paging'][$model];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,20 +141,20 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if (!empty($options['paging'])) {
|
||||
if (!isset($this->params['paging'])) {
|
||||
$this->params['paging'] = array();
|
||||
if (!isset($this->request->params['paging'])) {
|
||||
$this->request->params['paging'] = array();
|
||||
}
|
||||
$this->params['paging'] = array_merge($this->params['paging'], $options['paging']);
|
||||
$this->request->params['paging'] = array_merge($this->request->params['paging'], $options['paging']);
|
||||
unset($options['paging']);
|
||||
}
|
||||
$model = $this->defaultModel();
|
||||
|
||||
if (!empty($options[$model])) {
|
||||
if (!isset($this->params['paging'][$model])) {
|
||||
$this->params['paging'][$model] = array();
|
||||
if (!isset($this->request->params['paging'][$model])) {
|
||||
$this->request->params['paging'][$model] = array();
|
||||
}
|
||||
$this->params['paging'][$model] = array_merge(
|
||||
$this->params['paging'][$model], $options[$model]
|
||||
$this->request->params['paging'][$model] = array_merge(
|
||||
$this->request->params['paging'][$model], $options[$model]
|
||||
);
|
||||
unset($options[$model]);
|
||||
}
|
||||
|
@ -486,10 +486,10 @@ class PaginatorHelper extends AppHelper {
|
|||
if ($this->__defaultModel != null) {
|
||||
return $this->__defaultModel;
|
||||
}
|
||||
if (empty($this->params['paging'])) {
|
||||
if (empty($this->request->params['paging'])) {
|
||||
return null;
|
||||
}
|
||||
list($this->__defaultModel) = array_keys($this->params['paging']);
|
||||
list($this->__defaultModel) = array_keys($this->request->params['paging']);
|
||||
return $this->__defaultModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,26 +37,29 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function setUp() {
|
||||
$this->Paginator = new PaginatorHelper();
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Article' => array(
|
||||
'current' => 9,
|
||||
'count' => 62,
|
||||
'prevPage' => false,
|
||||
'nextPage' => true,
|
||||
'pageCount' => 7,
|
||||
'defaults' => array(
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'page' => 1,
|
||||
'conditions' => array()
|
||||
$this->Paginator->request = new CakeRequest(null, false);
|
||||
$this->Paginator->request->addParams(array(
|
||||
'paging' => array(
|
||||
'Article' => array(
|
||||
'current' => 9,
|
||||
'count' => 62,
|
||||
'prevPage' => false,
|
||||
'nextPage' => true,
|
||||
'pageCount' => 7,
|
||||
'defaults' => array(
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'page' => 1,
|
||||
'conditions' => array()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
));
|
||||
$this->Paginator->Html = new HtmlHelper();
|
||||
$this->Paginator->Js = new PaginatorMockJsHelper();
|
||||
|
||||
|
@ -82,9 +85,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testHasPrevious() {
|
||||
$this->assertIdentical($this->Paginator->hasPrev(), false);
|
||||
$this->Paginator->params['paging']['Article']['prevPage'] = true;
|
||||
$this->Paginator->request->params['paging']['Article']['prevPage'] = true;
|
||||
$this->assertIdentical($this->Paginator->hasPrev(), true);
|
||||
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
||||
$this->Paginator->request->params['paging']['Article']['prevPage'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,9 +98,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testHasNext() {
|
||||
$this->assertIdentical($this->Paginator->hasNext(), true);
|
||||
$this->Paginator->params['paging']['Article']['nextPage'] = false;
|
||||
$this->Paginator->request->params['paging']['Article']['nextPage'] = false;
|
||||
$this->assertIdentical($this->Paginator->hasNext(), false);
|
||||
$this->Paginator->params['paging']['Article']['nextPage'] = true;
|
||||
$this->Paginator->request->params['paging']['Article']['nextPage'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,13 +110,13 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testDisabledLink() {
|
||||
$this->Paginator->params['paging']['Article']['nextPage'] = false;
|
||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||
$this->Paginator->request->params['paging']['Article']['nextPage'] = false;
|
||||
$this->Paginator->request->params['paging']['Article']['page'] = 1;
|
||||
$result = $this->Paginator->next('Next', array(), true);
|
||||
$expected = '<span class="next">Next</span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
||||
$this->Paginator->request->params['paging']['Article']['prevPage'] = false;
|
||||
$result = $this->Paginator->prev('prev', array('update' => 'theList', 'indicator' => 'loading', 'url' => array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span'));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'disabled'), 'prev', '/span'
|
||||
|
@ -167,7 +170,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = 'title';
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = 'title';
|
||||
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc', 'class' => 'asc'),
|
||||
|
@ -176,37 +179,37 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('title');
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('title');
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc'));
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'asc'));
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'asc'));
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc'));
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
|
||||
}
|
||||
|
@ -259,7 +262,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array())
|
||||
));
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$result = $this->Paginator->sort('Title','Article.title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'),
|
||||
|
@ -268,7 +271,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$result = $this->Paginator->sort('Title','Article.title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc', 'class' => 'asc'),
|
||||
|
@ -277,7 +280,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
|
||||
$result = $this->Paginator->sort('title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:title/direction:asc'),
|
||||
|
@ -318,48 +321,48 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'desc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'asc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('title' => 'desc');
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('title' => 'desc');
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'desc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('title' => 'asc');
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('title' => 'asc');
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'asc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
$this->Paginator->params['paging']['Article']['options']['direction'] = 'asc';
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$this->Paginator->request->params['paging']['Article']['options']['direction'] = 'asc';
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'asc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
$this->Paginator->params['paging']['Article']['options']['direction'] = 'desc';
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$this->Paginator->request->params['paging']['Article']['options']['direction'] = 'desc';
|
||||
$result = $this->Paginator->sortDir();
|
||||
$expected = 'desc';
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
unset($this->Paginator->params['paging']['Article']['options']);
|
||||
unset($this->Paginator->request->params['paging']['Article']['options']);
|
||||
$result = $this->Paginator->sortDir('Article', array('direction' => 'asc'));
|
||||
$expected = 'asc';
|
||||
|
||||
|
@ -391,7 +394,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('base' => '', 'here' => '/admin/users', 'webroot' => '/')
|
||||
));
|
||||
Router::parse('/admin/users');
|
||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||
$this->Paginator->request->params['paging']['Article']['page'] = 1;
|
||||
$result = $this->Paginator->next('Next');
|
||||
$expected = array(
|
||||
'<span',
|
||||
|
@ -445,7 +448,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->url();
|
||||
$this->assertEqual($result, '/index/page:1');
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
|
||||
$result = $this->Paginator->url();
|
||||
$this->assertEqual($result, '/index/page:2');
|
||||
|
||||
|
@ -453,7 +456,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->url($options);
|
||||
$this->assertEqual($result, '/index/page:2/sort:Article/direction:desc');
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['page'] = 3;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 3;
|
||||
$options = array('order' => array('Article.name' => 'desc'));
|
||||
$result = $this->Paginator->url($options);
|
||||
$this->assertEqual($result, '/index/page:3/sort:Article.name/direction:desc');
|
||||
|
@ -478,9 +481,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => 'posts/index', 'webroot' => '/')
|
||||
));
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
||||
$this->Paginator->params['paging']['Article']['page'] = 2;
|
||||
$this->Paginator->params['paging']['Article']['prevPage'] = true;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Article']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Article']['prevPage'] = true;
|
||||
$options = array('members' => true);
|
||||
|
||||
$result = $this->Paginator->url($options);
|
||||
|
@ -539,7 +542,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->assertEqual('myDiv', $this->Paginator->options['update']);
|
||||
|
||||
$this->Paginator->options = array();
|
||||
$this->Paginator->params = array();
|
||||
$this->Paginator->request->params = array();
|
||||
|
||||
$options = array('paging' => array('Article' => array(
|
||||
'order' => 'desc',
|
||||
|
@ -551,17 +554,17 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'order' => 'desc',
|
||||
'sort' => 'title'
|
||||
));
|
||||
$this->assertEqual($expected, $this->Paginator->params['paging']);
|
||||
$this->assertEqual($expected, $this->Paginator->request->params['paging']);
|
||||
|
||||
$this->Paginator->options = array();
|
||||
$this->Paginator->params = array();
|
||||
$this->Paginator->request->params = array();
|
||||
|
||||
$options = array('Article' => array(
|
||||
'order' => 'desc',
|
||||
'sort' => 'title'
|
||||
));
|
||||
$this->Paginator->options($options);
|
||||
$this->assertEqual($expected, $this->Paginator->params['paging']);
|
||||
$this->assertEqual($expected, $this->Paginator->request->params['paging']);
|
||||
|
||||
$options = array('paging' => array('Article' => array(
|
||||
'order' => 'desc',
|
||||
|
@ -573,7 +576,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'order' => 'desc',
|
||||
'sort' => 'Article.title'
|
||||
));
|
||||
$this->assertEqual($expected, $this->Paginator->params['paging']);
|
||||
$this->assertEqual($expected, $this->Paginator->request->params['paging']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -589,7 +592,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'form' => array(), 'url' => array('url' => 'articles/index/2/foo:bar'), 'bare' => 0),
|
||||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar'))
|
||||
));
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Article' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13,
|
||||
'prevPage' => false, 'nextPage' => true, 'pageCount' => 8,
|
||||
|
@ -602,8 +605,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
)
|
||||
);
|
||||
|
||||
$this->Paginator->params['pass'] = array(2);
|
||||
$this->Paginator->params['named'] = array('foo' => 'bar');
|
||||
$this->Paginator->request->params['pass'] = array(2);
|
||||
$this->Paginator->request->params['named'] = array('foo' => 'bar');
|
||||
$this->Paginator->beforeRender();
|
||||
|
||||
$result = $this->Paginator->sort('title');
|
||||
|
@ -650,7 +653,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPagingLinks() {
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -671,8 +674,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Client']['prevPage'] = true;
|
||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$expected = array(
|
||||
'<span',
|
||||
|
@ -723,7 +726,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array(),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -753,14 +756,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array(),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Client']['prevPage'] = true;
|
||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$expected = array(
|
||||
'<span',
|
||||
|
@ -781,7 +784,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2,
|
||||
'defaults' => array(),
|
||||
'options' => array('page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array())
|
||||
|
@ -796,7 +799,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
|
||||
'nextPage' => false, 'pageCount' => 2,
|
||||
|
@ -825,7 +828,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false,
|
||||
'nextPage' => true, 'pageCount' => 5,
|
||||
|
@ -866,7 +869,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testPagingLinksNotDefaultModel() {
|
||||
// Multiple Model Paginate
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array( 'limit'=>3, 'order' => array('Client.name' => 'DESC')),
|
||||
|
@ -910,7 +913,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
|
||||
$result = $this->Paginator->link('Sort by title', array('sort' => 'title', 'direction' => 'desc'));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:2/sort:title/direction:desc'),
|
||||
|
@ -919,7 +922,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['page'] = 4;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 4;
|
||||
$result = $this->Paginator->link('Sort by title on page 4', array('sort' => 'Article.title', 'direction' => 'desc'));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:4/sort:Article.title/direction:desc'),
|
||||
|
@ -974,7 +977,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testNumbers() {
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 8, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1063,7 +1066,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1091,7 +1094,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1118,7 +1121,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1168,7 +1171,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1199,7 +1202,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1231,7 +1234,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 6, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1263,7 +1266,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
|
||||
'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 37, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1295,7 +1298,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 10,
|
||||
|
@ -1328,7 +1331,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4,
|
||||
'defaults' => array('limit' => 10),
|
||||
'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1346,7 +1349,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
|
||||
'defaults' => array('limit' => 10),
|
||||
'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array()))
|
||||
|
@ -1368,7 +1371,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 3;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 3;
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
|
||||
$expected = array(
|
||||
|
@ -1428,7 +1431,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 4893;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 4893;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||
|
@ -1457,7 +1460,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 58;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 58;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||
|
@ -1492,7 +1495,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 5;
|
||||
$this->Paginator->request->params['paging']['Client']['page'] = 5;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||
|
@ -1529,7 +1532,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testFirstAndLast() {
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1539,7 +1542,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$expected = '';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1612,7 +1615,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1621,7 +1624,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$expected = '';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
$this->Paginator->request->params['paging'] = array('Client' => array(
|
||||
'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
|
@ -1673,7 +1676,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testCounter() {
|
||||
$this->Paginator->params['paging'] = array(
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 3,
|
||||
|
@ -1810,8 +1813,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array())
|
||||
));
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->request->params['paging']['Article']['page'] = 1;
|
||||
|
||||
$test = array('url'=> array(
|
||||
'page'=> '1',
|
||||
|
@ -1864,7 +1867,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testMockAjaxProviderClassInjection() {
|
||||
$Paginator = new PaginatorHelper(array('ajax' => 'PaginatorMockJs'));
|
||||
$Paginator->params['paging'] = array(
|
||||
$Paginator->request->params['paging'] = array(
|
||||
'Article' => array(
|
||||
'current' => 9,
|
||||
'count' => 62,
|
||||
|
|
Loading…
Add table
Reference in a new issue