You are here

public function ViewsBaseUrlFieldTest::testViewsBaseUrlLinkLinkPath in Views base url 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/ViewsBaseUrlFieldTest.php \Drupal\Tests\views_base_url\Functional\ViewsBaseUrlFieldTest::testViewsBaseUrlLinkLinkPath()

Tests views base url field when `show_link` enabled and `link_path` set.

File

tests/src/Functional/ViewsBaseUrlFieldTest.php, line 207

Class

ViewsBaseUrlFieldTest
Basic test for views base url.

Namespace

Drupal\Tests\views_base_url\Functional

Code

public function testViewsBaseUrlLinkLinkPath() {
  global $base_url;
  $this
    ->drupalGet('views-base-url-link-link-path-test');
  $this
    ->assertResponse(200);
  $elements = $this
    ->xpath('//div[contains(@class,"view-views-base-url-link-link-path-test")]/div[@class="view-content"]/div[contains(@class,"views-row")]');
  $this
    ->assertEqual(count($elements), $this->nodeCount, t('There are @count rows', [
    '@count' => $this->nodeCount,
  ]));
  foreach ($this->nodes as $node) {
    $link_path = Url::fromUri($base_url . $this->pathAliasManager
      ->getAliasByPath('/node/' . $node
      ->id()))
      ->toUriString();
    $link_text = $link_path;
    $elements = $this
      ->xpath('//a[@href=:path and text()=:text]', [
      ':path' => $link_path,
      ':text' => $link_text,
    ]);
    $this
      ->assertEqual(count($elements), 1, 'Views base url rendered as link with link path set');
  }
}