You are here

public function ContactLinkTest::assertContactLinks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/contact/src/Tests/Views/ContactLinkTest.php \Drupal\contact\Tests\Views\ContactLinkTest::assertContactLinks()

Asserts whether certain users contact links appear on the page.

Parameters

array $accounts: All user objects used by the test.

array $names: Users which should have contact links.

1 call to ContactLinkTest::assertContactLinks()
ContactLinkTest::testContactLink in core/modules/contact/src/Tests/Views/ContactLinkTest.php
Tests contact link.

File

core/modules/contact/src/Tests/Views/ContactLinkTest.php, line 102
Contains \Drupal\contact\Tests\Views\ContactLinkTest.

Class

ContactLinkTest
Tests the contact link field.

Namespace

Drupal\contact\Tests\Views

Code

public function assertContactLinks(array $accounts, array $names) {
  $result = $this
    ->xpath('//div[contains(@class, "views-field-contact")]//a');
  $this
    ->assertEqual(count($result), count($names));
  foreach ($names as $name) {
    $account = $accounts[$name];
    $result = $this
      ->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', array(
      ':url' => $account
        ->url('contact-form'),
    ));
    $this
      ->assertTrue(count($result));
  }
}