Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10pest()->group('unit');
11
12use AppDemo\Shared\Application\Middleware\RbacPermissionMiddleware;
13use AppDemo\Shared\Infrastructure\RbacMiddlewareFactory;
14use AppDemo\Shared\Infrastructure\RbacPermissionService;
15use Nyholm\Psr7\Factory\Psr17Factory;
16use Phexium\Plugin\Authorization\Adapter\RbacAuthorizationService;
17
18describe('Factory creation', function (): void {
19    it('returns a RbacPermissionMiddleware instance', function (): void {
20        $authorizationService = new RbacAuthorizationService([]);
21        $rbacService = new RbacPermissionService($authorizationService);
22        $responseFactory = new Psr17Factory();
23        $factory = new RbacMiddlewareFactory($rbacService, $responseFactory);
24
25        $middleware = $factory->forPermission('dummy.permission');
26
27        expect($middleware)->toBeInstanceOf(RbacPermissionMiddleware::class);
28    });
29});