Skip to content

Commit

Permalink
Fix paginator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 23, 2020
1 parent 98a874b commit 542eb5f
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions tests/TestCase/View/Helper/PaginatorHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ public function setUp()

Configure::write('Config.language', 'eng');

$request = new ServerRequest();
$request = new ServerRequest([
'params' => [
'plugin' => null,
'controller' => 'Clients',
'action' => 'index',
'_ext' => null,
'pass' => [],
],
]);
$request = $request->withParam('paging', [
'Article' => [
'page' => 1,
Expand All @@ -65,7 +73,7 @@ public function setUp()
Configure::write('Routing.prefixes', []);
Router::reload();
Router::connect('/:controller/:action/*');
Router::connect('/:plugin/:controller/:action/*');
Router::pushRequest($request);

$this->locale = I18n::getLocale();
}
Expand Down Expand Up @@ -100,19 +108,21 @@ public function testLinks()
'pageCount' => 15,
]
]);
Router::pushRequest($request);

$this->Paginator->getView()->setRequest($request);
$result = $this->Paginator->links();
$expected = [
'ul' => ['class' => 'pagination'],
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=4']], '4', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=5']], '5', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=6']], '6', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=7']], '7', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=4']], '4', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=5']], '5', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=6']], '6', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=7']], '7', '/a', '/li',
['li' => ['class' => 'page-item active']], ['a' => ['class' => 'page-link', 'href' => '#']], '8', ['span' => ['class' => 'sr-only']], '(current)', '/span', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=9']], '9', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=10']], '10', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=11']], '11', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=12']], '12', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=9']], '9', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=10']], '10', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=11']], '11', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=12']], '12', '/a', '/li',
'/ul'
];
$this->assertHtml($expected, $result);
Expand All @@ -131,19 +141,19 @@ public function testLinks()
$result = $this->Paginator->links(['prev' => true, 'next' => true, 'first' => true, 'last' => true]);
$expected = [
'ul' => ['class' => 'pagination'],
['li' => ['class' => 'page-item first']], ['a' => ['class' => 'page-link', 'href' => '/index']], '«', '/a', '/li',
['li' => ['class' => 'page-item first']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index']], '«', '/a', '/li',
['li' => ['class' => 'page-item disabled']], ['a' => ['class' => 'page-link', 'tabindex' => '-1']], ['span' => ['aria-hidden' => 'true']], '‹', '/span', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=4']], '4', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=5']], '5', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=6']], '6', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=7']], '7', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=4']], '4', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=5']], '5', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=6']], '6', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=7']], '7', '/a', '/li',
['li' => ['class' => 'page-item active']], ['a' => ['class' => 'page-link', 'href' => '#']], '8', ['span' => ['class' => 'sr-only']], '(current)', '/span', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=9']], '9', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=10']], '10', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=11']], '11', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=12']], '12', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'rel' => 'next', 'aria-label' => 'Next', 'href' => '/index?page=9']], ['span' => ['aria-hidden' => 'true']], '›', '/span', '/a', '/li',
['li' => ['class' => 'page-item last']], ['a' => ['class' => 'page-link', 'href' => '/index?page=15']], '»', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=9']], '9', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=10']], '10', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=11']], '11', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=12']], '12', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'rel' => 'next', 'aria-label' => 'Next', 'href' => '/Clients/index?page=9']], ['span' => ['aria-hidden' => 'true']], '›', '/span', '/a', '/li',
['li' => ['class' => 'page-item last']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=15']], '»', '/a', '/li',
'/ul'
];
$this->assertHtml($expected, $result);
Expand All @@ -163,7 +173,7 @@ public function testLinks()
$expected = [
'ul' => ['class' => 'pagination pagination-lg'],
['li' => ['class' => 'page-item active']], 'a' => ['class' => 'page-link', 'href' => '#'], '1', 'span' => ['class' => 'sr-only'], '(current)', '/span', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/index?page=2']], '2', '/a', '/li',
['li' => ['class' => 'page-item']], ['a' => ['class' => 'page-link', 'href' => '/Clients/index?page=2']], '2', '/a', '/li',
'/ul'
];
$this->assertHtml($expected, $result);
Expand Down

0 comments on commit 542eb5f

Please sign in to comment.