Browse Source

Merge pull request #7611 from cakephp/master-paginator

Make sure direction values are lowercased to be consistent.
José Lorenzo Rodríguez 10 years ago
parent
commit
706f0b2b4b

+ 1 - 1
src/View/Helper/PaginatorHelper.php

@@ -402,7 +402,7 @@ class PaginatorHelper extends Helper
 
 
             $title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)));
             $title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)));
         }
         }
-        $defaultDir = isset($options['direction']) ? $options['direction'] : 'asc';
+        $defaultDir = isset($options['direction']) ? strtolower($options['direction']) : 'asc';
         unset($options['direction']);
         unset($options['direction']);
 
 
         $locked = isset($options['lock']) ? $options['lock'] : false;
         $locked = isset($options['lock']) ? $options['lock'] : false;

+ 1 - 1
tests/TestCase/View/Helper/PaginatorHelperTest.php

@@ -233,7 +233,7 @@ class PaginatorHelperTest extends TestCase
 
 
         $this->Paginator->request->params['paging']['Article']['sort'] = 'Article.title';
         $this->Paginator->request->params['paging']['Article']['sort'] = 'Article.title';
         $this->Paginator->request->params['paging']['Article']['direction'] = 'desc';
         $this->Paginator->request->params['paging']['Article']['direction'] = 'desc';
-        $result = $this->Paginator->sort('title', 'Title', ['direction' => 'asc']);
+        $result = $this->Paginator->sort('title', 'Title', ['direction' => 'ASC']);
         $expected = [
         $expected = [
             'a' => ['href' => '/accounts/index/param?sort=title&direction=asc', 'class' => 'desc'],
             'a' => ['href' => '/accounts/index/param?sort=title&direction=asc', 'class' => 'desc'],
             'Title',
             'Title',