You are here

public function AvatarKitManagerTest::testGetAvatarGeneratorsForUser in Avatar Kit 8

Test default behaviour of testGetAvatarGeneratorsForUser().

Get all avatar generators for a user excluding user_preference plugins.

@covers ::getAvatarGeneratorsForUser

File

tests/src/Kernel/AvatarKitManagerTest.php, line 62

Class

AvatarKitManagerTest
Tests Avatar Manager.

Namespace

Drupal\Tests\avatars\Kernel

Code

public function testGetAvatarGeneratorsForUser() {
  $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);
  $this
    ->assertEquals(1, count($generators));
}