You are here

public function AvatarKitGeneratorTest::testGenerator in Avatar Kit 8

Test avatar generators.

File

tests/src/Functional/AvatarKitGeneratorTest.php, line 21

Class

AvatarKitGeneratorTest
Avatar Kit generator test.

Namespace

Drupal\Tests\avatars\Functional

Code

public function testGenerator() {
  $this
    ->deleteAvatarGenerators();
  $avatar_generator1 = $this
    ->createAvatarGenerator();
  $user = $this
    ->createUser([
    'administer avatars',
    'avatars avatar_generator user ' . $avatar_generator1
      ->id(),
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->setAvatarGeneratorPreferences([
    $avatar_generator1
      ->id() => TRUE,
  ]);
  $this
    ->drupalGet('admin/config/people/avatars');

  /** @var \Drupal\avatars\AvatarManagerInterface $am */
  $am = \Drupal::service('avatars.avatar_manager');
  $avatar_preview = $am
    ->findValidAvatar($user);
  $this
    ->assertTrue($avatar_preview instanceof AvatarPreviewInterface, 'Downloaded avatar');
}