Failed Conditions
Pull Request — master (#13)
by Adrien
05:33 queued 02:11
created

AbstractAcl   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 36
ccs 0
cts 13
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRole() 0 27 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Testing\Acl;
6
7
use Ecodev\Felix\Acl\Acl;
8
use PHPUnit\Framework\TestCase;
9
10
abstract class AbstractAcl extends TestCase
11
{
12
    abstract protected function createAcl(): Acl;
13
14
    abstract public function providerRole(): iterable;
15
16
    /**
17
     * @dataProvider providerRole
18
     */
19
    final public function testRole(string $role): void
20
    {
21
        $acl = $this->createAcl();
22
        $actual = $acl->show($role);
23
24
        $file = "tests/data/acl/$role.php";
25
        $logFile = "logs/$file";
26
27
        $dir = dirname($logFile);
28
        @mkdir($dir, 0o777, true);
0 ignored issues
show
Bug introduced by
The constant Ecodev\Felix\Testing\Acl\0o777 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
29
        $serialized = ve($actual, true);
30
        file_put_contents(
31
            $logFile,
32
            <<<STRING
33
                <?php
34
35
                declare(strict_types=1);
36
37
                return $serialized;
38
39
                STRING
40
        );
41
42
        self::assertFileExists($file, 'Expected file must exist on disk, fix it with: cp ' . $logFile . ' ' . $file);
43
44
        $expected = require $file;
45
        self::assertTrue($expected === $actual, 'File content does not match, compare with: meld ' . $file . ' ' . $logFile);
46
    }
47
}
48