function DevelSwitchUserTest::assertSwitchUserListContainsUser

Same name in other branches
  1. 5.x 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,
    ]));
}