public function EntityPagerTest::testRelationship in Entity Pager 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/EntityPagerTest.php \Drupal\Tests\entity_pager\Functional\EntityPagerTest::testRelationship()
Tests pager with relationships.
File
- tests/
src/ Functional/ EntityPagerTest.php, line 268
Class
- EntityPagerTest
- Tests the entity pager view style.
Namespace
Drupal\Tests\entity_pager\FunctionalCode
public function testRelationship() {
ViewTestData::createTestViews(self::class, [
'entity_pager_test_views',
]);
$this
->drupalPlaceBlock('views_block:test_relationship_pager-block_1', [
'id' => 'test',
]);
$this
->drupalGet($this->nodes[1]
->toUrl());
$elements = $this
->cssSelect('#block-test .entity-pager-item-prev a');
$this
->assertCount(1, $elements, 'Previous link exists.');
$link = reset($elements);
$expected = $this->nodes[0]
->toUrl()
->toString();
$this
->assertEquals($expected, $link
->getAttribute('href'), 'Previous link points to previous view row.');
$elements = $this
->cssSelect('#block-test .entity-pager-item-next a');
$this
->assertCount(1, $elements, 'Next link exists.');
$link = reset($elements);
$expected = $this->nodes[2]
->toUrl()
->toString();
$this
->assertEquals($expected, $link
->getAttribute('href'), 'Next link points to next view row.');
$link = $this
->cssSelect('#block-test .entity-pager-item-all a')[0];
$expected = (string) $this->nodes[1]
->id();
$this
->assertEquals("Node {$expected}", trim($link
->getText()), 'Node context token text replacement.');
}