RequestPagerTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Pager/RequestPagerTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Pager;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
class RequestPagerTest extends KernelTestBase {
public function testFindPage() {
$request = Request::create('http://example.com', 'GET', [
'page' => '0,10',
]);
$request_stack = $this->container
->get('request_stack');
$request_stack
->push($request);
$pager_params = $this->container
->get('pager.parameters');
$this
->assertEquals(10, $pager_params
->findPage(1));
}
public function testGetQueryParameters() {
$test_parameters = [
'other' => 'arbitrary',
];
$request = Request::create('http://example.com', 'GET', array_merge([
'page' => '0,10',
], $test_parameters));
$request_stack = $this->container
->get('request_stack');
$request_stack
->push($request);
$pager_params = $this->container
->get('pager.parameters');
$this
->assertEquals($test_parameters, $pager_params
->getQueryParameters());
$this
->assertEquals(0, $pager_params
->findPage());
}
}