how to functional test sites with knp_pagination_sortable()?

224 Views Asked by At

How to functional test sites with knp_pagination_sortable() ?

<th>{{ knp_pagination_sortable(foo) }}</th>

In browser same url got different content than in functional test.

$crawler = $client->request('GET', '/ksiazka/?sort=a.wydawnictwo&direction=asc&page=1');
$this->assertGreaterThan(1, $crawler->filter('a:contains("ill")')->count());
//Failed asserting that 1 is greater than 1.

enter image description here

The issue was also pointed out there with a clue:

  • underlying paging library (knp-components) is independent to Symfony's Request/Response system and extracts $_GET parameters directly

  • Symfony's functional tests aren't actually making a real HTTP request, they are simply constructing a Request object and passing it through the application.

1

There are 1 best solutions below

1
On

Seems you are testing absolute address with variables in there and the controller not receive any of this.

Probably knp paginator component generate sortable url. Try generate an url in the test with the knp-paginator component or check better the url you are testing