AvatarKitPermissionsTest.php in Avatar Kit 8
File
tests/src/Kernel/AvatarKitPermissionsTest.php
View source
<?php
namespace Drupal\Tests\avatars\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\avatars\Entity\AvatarGenerator;
use Drupal\Tests\user\Traits\UserCreationTrait;
class AvatarKitPermissionsTest extends KernelTestBase {
use UserCreationTrait;
public static $modules = [
'avatars',
'user',
'avatars_test',
'system',
'file',
];
protected $permissionHandler;
protected function setUp() {
parent::setUp();
$this->permissionHandler = $this->container
->get('user.permissions');
}
public function testPermissions() {
$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();
$permissions = $this->permissionHandler
->getPermissions();
$this
->assertFalse(isset($permissions['avatars avatar_generator user ' . $generator_1
->id()]));
$this
->assertTrue(isset($permissions['avatars avatar_generator user ' . $generator_2
->id()]));
}
}