Permalink
Browse files

pach fix + test

  • Loading branch information...
1 parent e587faf commit 0d6a6e5033af04a65129f716343266aa211c2a63 @ch0c4 ch0c4 committed Feb 15, 2014
Showing with 35 additions and 2 deletions.
  1. +2 −2 src/View/Helper/PaginatorHelper.php
  2. +33 −0 tests/TestCase/View/Helper/PaginatorHelperTest.php
@@ -427,8 +427,8 @@ public function url($options = array(), $model = null) {
$url['page'] = null;
}
if (isset($paging['sortDefault'], $paging['directionDefault'], $url['sort'], $url['direction']) && $url['sort'] === $paging['sortDefault'] && $url['direction'] === $paging['directionDefault'] ) {
- $url['sort'] = $url['direction'] = null;
- }
+ $url['sort'] = $url['direction'] = null;
+ }
return parent::url($url);
}
@@ -544,6 +544,35 @@ public function testSortAdminLinks() {
}
/**
+ * Test that generated URLs work without sort defined within the request
+ *
+ * @return void
+ */
+ public function testDefaultSortAndNoSort() {
+ Router::setRequestInfo(array(
+ array('plugin' => null, 'controller' => 'articles', 'action' => 'index'),
+ array('base' => '/', 'here' => '/articles/', 'webroot' => '/')
+ ));
+ $this->Paginator->request->params['paging'] = array(
+ 'Article' => array(
+ 'page' => 1, 'current' => 3, 'count' => 13,
+ 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8,
+ 'sortDefault' => 'Article.title', 'directionDefault' => 'ASC',
+ 'sort' => null
+ )
+ );
+ $result = $this->Paginator->next('Next');
+ $expected = array(
+ 'li' => array('class' => 'next'),
+ 'a' => array('rel' => 'next', 'href' => '/articles/index?page=2'),
+ 'Next',
+ '/a',
+ '/li'
+ );
+ $this->assertTags($result, $expected);
+ }
+
+/**
* testUrlGeneration method
*
* @return void
@@ -560,6 +589,10 @@ public function testUrlGeneration() {
$result = $this->Paginator->url();
$this->assertEquals('/index', $result);
+ $file = fopen('/home/johan/test/log.txt', 'r+');
+
+ fwrite($file, $result);
+
$this->Paginator->request->params['paging']['Article']['page'] = 2;
$result = $this->Paginator->url();
$this->assertEquals('/index?page=2', $result);

0 comments on commit 0d6a6e5

Please sign in to comment.