public function UserMatcherTest::testUserMatcherWidthIncludeBlocked in Linkit 8.5
Tests user matcher with include blocked setting activated.
File
- tests/
src/ Kernel/ Matchers/ UserMatcherTest.php, line 97
Class
- UserMatcherTest
- Tests user matcher.
Namespace
Drupal\Tests\linkit\Kernel\MatchersCode
public function testUserMatcherWidthIncludeBlocked() {
/** @var \Drupal\linkit\MatcherInterface $plugin */
$plugin = $this->manager
->createInstance('entity:user', [
'settings' => [
'include_blocked' => TRUE,
],
]);
// Test without permissions to see blocked users.
$suggestions = $plugin
->execute('blocked');
$this
->assertEquals(0, count($suggestions
->getSuggestions()), 'Correct number of suggestions');
// Set the current user to a user with 'administer users' permission.
\Drupal::currentUser()
->setAccount($this
->createUser([], [
'administer users',
]));
// Test with permissions to see blocked users.
$suggestions = $plugin
->execute('blocked');
$this
->assertEquals(1, count($suggestions
->getSuggestions()), 'Correct number of suggestions');
}