You are here

public function DevelSwitchUserTest::assertSwitchUserListContainsUser in Devel 4.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertSwitchUserListContainsUser()
  2. 8 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertSwitchUserListContainsUser()
  3. 8.2 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertSwitchUserListContainsUser()

Helper function for verify if the user list contains a username.

Parameters

string $username: The username to check.

2 calls to DevelSwitchUserTest::assertSwitchUserListContainsUser()
DevelSwitchUserTest::testSwitchUserBlockConfiguration in tests/src/Functional/DevelSwitchUserTest.php
Tests the switch user block configuration.
DevelSwitchUserTest::testSwitchUserListItems in tests/src/Functional/DevelSwitchUserTest.php
Test the user list items.

File

tests/src/Functional/DevelSwitchUserTest.php, line 225

Class

DevelSwitchUserTest
Tests switch user.

Namespace

Drupal\Tests\devel\Functional

Code

public function assertSwitchUserListContainsUser($username) {
  $result = $this
    ->xpath('//div[@id=:block]//ul/li/a[normalize-space()=:user]', [
    ':block' => 'block-switch-user',
    ':user' => $username,
  ]);
  $this
    ->assertTrue(count($result) > 0, new FormattableMarkup('User "%user" is included in the switch user list.', [
    '%user' => $username,
  ]));
}