Updating PaginatorHelper::options() docblock and adding test cases to demonstrate correct usage, closes #5380

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7556 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-09-04 19:10:15 +00:00
parent 2a84ec9944
commit ccc602c82a
2 changed files with 40 additions and 2 deletions

View file

@ -50,14 +50,15 @@ class PaginatorHelper extends AppHelper {
* Holds the default options for pagination links * Holds the default options for pagination links
* *
* The values that may be specified are: * The values that may be specified are:
* - <i>$options['sort']</i> the key that the recordset is sorted.
* - <i>$options['direction']</i> Direction of the sorting (default: 'asc').
* - <i>$options['format']</i> Format of the counter. Supported formats are 'range' and 'pages' * - <i>$options['format']</i> Format of the counter. Supported formats are 'range' and 'pages'
* and custom (default). In the default mode the supplied string is * and custom (default). In the default mode the supplied string is
* parsed and constants are replaced by their actual values. * parsed and constants are replaced by their actual values.
* Constants: %page%, %pages%, %current%, %count%, %start%, %end% . * Constants: %page%, %pages%, %current%, %count%, %start%, %end% .
* - <i>$options['separator']</i> The separator of the actual page and number of pages (default: ' of '). * - <i>$options['separator']</i> The separator of the actual page and number of pages (default: ' of ').
* - <i>$options['url']</i> Url of the action. See Router::url() * - <i>$options['url']</i> Url of the action. See Router::url()
* - <i>$options['url']['sort']</i> the key that the recordset is sorted.
* - <i>$options['url']['direction']</i> Direction of the sorting (default: 'asc').
* - <i>$options['url']['page']</i> Page # to display.
* - <i>$options['model']</i> The name of the model. * - <i>$options['model']</i> The name of the model.
* - <i>$options['escape']</i> Defines if the title field for the link should be escaped (default: true). * - <i>$options['escape']</i> Defines if the title field for the link should be escaped (default: true).
* - <i>$options['update']</i> DOM id of the element updated with the results of the AJAX call. * - <i>$options['update']</i> DOM id of the element updated with the results of the AJAX call.

View file

@ -398,6 +398,43 @@ class PaginatorTest extends CakeTestCase {
$this->assertPattern('/\/sort:Article.title/', $result); $this->assertPattern('/\/sort:Article.title/', $result);
$this->assertPattern('/\/direction:desc/', $result); $this->assertPattern('/\/direction:desc/', $result);
} }
/**
* Tests generation of generic links with preset options
*
* @access public
* @return void
*/
function testGenericLinksWithPresetOptions() {
$result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a'));
$this->Paginator->options(array('sort' => 'title', 'direction' => 'desc'));
$result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array(
'a' => array(
'href' => '/index/page:1',
'sort' => 'title',
'direction' => 'desc'
),
'Foo!',
'/a'
));
$this->Paginator->options(array('sort' => null, 'direction' => null));
$result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a'));
$this->Paginator->options(array('url' => array(
'sort' => 'title',
'direction' => 'desc'
)));
$result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array(
'a' => array('href' => '/index/page:1/sort:title/direction:desc'),
'Foo!',
'/a'
));
}
/** /**
* testNumbers method * testNumbers method
* *