feat(core) : add rbac seeder and seed-rbac command for system roles
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Functional\Module\Core;
|
||||
|
||||
use App\Module\Core\Domain\Repository\RoleRepositoryInterface;
|
||||
use App\Module\Core\Domain\Security\SystemRoles;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class SeedRbacCommandTest extends KernelTestCase
|
||||
{
|
||||
public function testSeedsSystemRolesIdempotently(): void
|
||||
{
|
||||
$kernel = self::bootKernel();
|
||||
$app = new Application($kernel);
|
||||
$tester = new CommandTester($app->find('app:seed-rbac'));
|
||||
|
||||
$tester->execute([]);
|
||||
$tester->assertCommandIsSuccessful();
|
||||
$tester->execute([]); // idempotent
|
||||
$tester->assertCommandIsSuccessful();
|
||||
|
||||
$repo = self::getContainer()->get(RoleRepositoryInterface::class);
|
||||
$admin = $repo->findByCode(SystemRoles::ADMIN_CODE);
|
||||
self::assertNotNull($admin);
|
||||
self::assertTrue($admin->isSystem());
|
||||
self::assertNotNull($repo->findByCode(SystemRoles::USER_CODE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user