You are here

public function AvatarKitGeneratorTest::testFileNotAvatarPreview in Avatar Kit 8

Tests whether a file is not matched with an avatar preview.

Tests AvatarManagerInterface::getAvatarPreviewByFile()

File

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

Class

AvatarKitGeneratorTest
Avatar Kit generator test.

Namespace

Drupal\Tests\avatars\Functional

Code

public function testFileNotAvatarPreview() {
  $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(),
  ]);

  /** @var \Drupal\avatars\AvatarManagerInterface $am */
  $am = \Drupal::service('avatars.avatar_manager');

  // Create a random file.
  $file = file_save_data($this
    ->randomString());
  $this
    ->assertFalse($am
    ->getAvatarPreviewByFile($file));
}