You are here

protected function OverviewPageTest::assertLocalAction in Search API 8

Asserts local actions in the page output.

Parameters

array $actions: A list of expected action link titles, keyed by the hrefs.

1 call to OverviewPageTest::assertLocalAction()
OverviewPageTest::checkServerAndIndexCreation in tests/src/Functional/OverviewPageTest.php
Tests the creation of a server and an index.

File

tests/src/Functional/OverviewPageTest.php, line 246

Class

OverviewPageTest
Tests the Search API overview page.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function assertLocalAction(array $actions) {
  $elements = $this
    ->xpath('//a[contains(@class, :class)]', [
    ':class' => 'button-action',
  ]);
  $index = 0;
  foreach ($actions as $action) {

    /** @var \Drupal\Core\Url $url */
    list($url, $title) = $action;

    // SimpleXML gives us the unescaped text, not the actual escaped markup,
    // so use a pattern instead to check the raw content.
    // This behaviour is a bug in libxml, see
    // https://bugs.php.net/bug.php?id=49437.
    $this
      ->assertSession()
      ->responseMatches('@<a [^>]*class="[^"]*button-action[^"]*"[^>]*>' . preg_quote($title, '@') . '</@');
    $this
      ->assertEquals($url
      ->toString(), $elements[$index++]
      ->getAttribute('href'));
  }
}