public function FieldTest::testClickSorting in Views (for Drupal 7) 8.3
Tests the click sorting functionality.
File
- lib/
Drupal/ views/ Tests/ Handler/ FieldTest.php, line 90 - Definition of Drupal\views\Tests\Handler\FieldTest.
Class
- FieldTest
- Tests the generic field handler.
Namespace
Drupal\views\Tests\HandlerCode
public function testClickSorting() {
$this
->drupalGet('test_click_sort');
$this
->assertResponse(200);
// Only the id and name should be click sortable, but not the name.
$this
->assertLinkByHref(url('test_click_sort', array(
'query' => array(
'order' => 'id',
'sort' => 'asc',
),
)));
$this
->assertLinkByHref(url('test_click_sort', array(
'query' => array(
'order' => 'name',
'sort' => 'desc',
),
)));
$this
->assertNoLinkByHref(url('test_click_sort', array(
'query' => array(
'order' => 'created',
),
)));
// Clicking a click sort should change the order.
$this
->clickLink(t('ID'));
$this
->assertLinkByHref(url('test_click_sort', array(
'query' => array(
'order' => 'id',
'sort' => 'desc',
),
)));
// Check that the output has the expected order (asc).
$ids = $this
->clickSortLoadIdsFromOutput();
$this
->assertEqual($ids, range(1, 5));
$this
->clickLink(t('ID'));
// Check that the output has the expected order (desc).
$ids = $this
->clickSortLoadIdsFromOutput();
$this
->assertEqual($ids, range(5, 1, -1));
}