public function AvatarKitGeneratorTest::testAnonymous in Avatar Kit 8
Ensure requesting avatar for anonymous does not crash the site.
File
- tests/
src/ Functional/ AvatarKitGeneratorTest.php, line 44
Class
- AvatarKitGeneratorTest
- Avatar Kit generator test.
Namespace
Drupal\Tests\avatars\FunctionalCode
public function testAnonymous() {
$generator_1 = AvatarGenerator::create([
'label' => $this
->randomMachineName(),
'id' => $this
->randomMachineName(),
'plugin' => 'avatars_test_static',
]);
$generator_1
->setStatus(TRUE)
->save();
// The anonymous role must be granted access to at least on generator
// otherwise nothing will tested.
Role::load(RoleInterface::ANONYMOUS_ID)
->grantPermission('avatars avatar_generator user ' . $generator_1
->id())
->save();
$anonymous = User::getAnonymousUser();
/** @var \Drupal\avatars\AvatarManagerInterface $am */
$am = \Drupal::service('avatars.avatar_manager');
$am
->syncAvatar($anonymous);
}