Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- better test for testExcludeVars(), also with the new regexp capabil…

…ities

- assertWantedPattern() was removed from SimpleTest


git-svn-id: https://svn.php.net/repository/pear/packages/Pager/trunk@257961 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 1b83afd9f280258e52d31edc3a9d6aa4ed224ed1 1 parent ea4ddce
@quipo quipo authored
Showing with 47 additions and 8 deletions.
  1. +47 −8 tests/pager_test.php
View
55 tests/pager_test.php
@@ -175,7 +175,7 @@ function testEscapeEntities() {
//$this->assertEqual($expected, $this->pager->_getLinksUrl());
$expected = 'request%5B0%5D=aRequest&escape=%E4%F6%25%3C%3E%2B';
- if (version_compare(phpversion(), '5.3.0-dev', '>=')) {
+ if (1 == version_compare(PHP_VERSION, '5.2.99')) {
$expected = 'request%5B0%5D=aRequest&escape=%C3%A4%C3%B6%25%3C%3E%2B';
}
$rendered = $this->pager->_renderLink('', '');
@@ -264,15 +264,23 @@ function testArrayExtraVars() {
$this->assertEqual($expected, $actual);
}
function testExcludeVars() {
- $arr = array(
- 'apple',
- 'orange',
+ $_GET['excludeMe'] = 'foo';
+ $extraVars = array(
+ 'arr' => array(
+ 'apple',
+ 'orange',
+ ),
+ 'no' => 'test', // do not remove this one, because it has been explicitely added
+ );
+ $excludeVars = array(
+ 'no', // do not remove, @see above
+ 'excludeMe', //remove
);
$options = array(
'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
'perPage' => 5,
- 'extraVars' => array('arr' => $arr, 'no' => 'test'),
- 'excludeVars' => array('no'),
+ 'extraVars' => $extraVars,
+ 'excludeVars' => $excludeVars,
);
$this->pager =& Pager::factory($options);
$expected = array(
@@ -283,14 +291,45 @@ function testExcludeVars() {
'no' => 'test',
);
$actual = $this->pager->_getLinksData();
- $this->assertEqual($expected, $this->pager->_getLinksData());
+ $this->assertEqual($expected, $actual);
$separator = ini_get('arg_separator.output');
if ($separator == '&') {
$separator = '&';
}
+
$expected = '<a href="'.$_SERVER['PHP_SELF'].'?arr%5B0%5D=apple'.$separator.'arr%5B1%5D=orange'.$separator.'no=test'.$separator.'pageID=2" title=""></a>';
$actual = $this->pager->_renderLink('', '');
$this->assertEqual($expected, $actual);
+ unset($_GET['excludeMe']); //cleanup
+
+ //exclude with regexp
+
+ $_GET['reMoveAAA'] = 'aaa';
+ $_GET['RemoveBBB'] = 'bbb';
+ $_GET['leaveCCC'] = 'ccc';
+ $excludeVars = array(
+ '/remove.*/i', //regexp
+ );
+ $options = array(
+ 'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+ 'perPage' => 5,
+ 'extraVars' => $extraVars,
+ 'excludeVars' => $excludeVars,
+ );
+ $this->pager =& Pager::factory($options);
+ $expected = array(
+ 'arr' => array(
+ 0 => 'apple',
+ 1 => 'orange'
+ ),
+ 'no' => 'test',
+ 'leaveCCC' => 'ccc',
+ );
+ $this->assertEqual($expected, $this->pager->_getLinksData());
+ //cleanup
+ foreach (array_keys($_GET) as $k) {
+ unset($_GET[$k]);
+ }
}
function testArgSeparator() {
$bkp_arg_separator = ini_get('arg_separator.output');
@@ -597,7 +636,7 @@ function testAccesskey() {
'accesskey' => true,
);
$this->pager = Pager::factory($options);
- $this->assertWantedPattern('/accesskey="\d"/i', $this->pager->links);
+ $this->assertPattern('/accesskey="\d"/i', $this->pager->links);
//var_dump($this->pager->links);
}
function testIsEncoded() {
Please sign in to comment.
Something went wrong with that request. Please try again.