public function AvatarKitManagerTest::testGetAvatarGeneratorsForUserWithPermissions in Avatar Kit 8
Get all avatar generators for a user including user_preference plugins.
@covers ::getAvatarGeneratorsForUser
File
- tests/
src/ Kernel/ AvatarKitManagerTest.php, line 94
Class
- AvatarKitManagerTest
- Tests Avatar Manager.
Namespace
Drupal\Tests\avatars\KernelCode
public function testGetAvatarGeneratorsForUserWithPermissions() {
$generator_1 = AvatarGenerator::create([
'label' => $this
->randomMachineName(),
'id' => $this
->randomMachineName(),
'plugin' => 'user_preference',
]);
$generator_1
->setStatus(TRUE)
->save();
$generator_2 = AvatarGenerator::create([
'label' => $this
->randomMachineName(),
'id' => $this
->randomMachineName(),
'plugin' => 'avatars_test_static',
]);
$generator_2
->setStatus(TRUE)
->save();
$user = $this
->createUser([
'avatars avatar_generator user ' . $generator_2
->id(),
]);
$generators = $this->avatarManager
->getAvatarGeneratorsForUser($user, FALSE);
$this
->assertEquals(2, count($generators));
}