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

AllTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
c 1
b 0
f 0
dl 0
loc 57
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A providerAssert() 0 10 1
A testAssert() 0 16 2
A setUp() 0 3 1
A testGetName() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Acl\Assertion;
6
7
use Ecodev\Felix\Acl\Acl;
8
use Ecodev\Felix\Acl\Assertion\All;
1 ignored issue
show
Bug introduced by
The type Ecodev\Felix\Acl\Assertion\All was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Ecodev\Felix\Acl\Assertion\NamedAssertion;
10
use EcodevTests\Felix\Traits\TestWithContainer;
11
use PHPUnit\Framework\TestCase;
12
13
class AllTest extends TestCase
14
{
15
    use TestWithContainer;
16
17
    protected function setUp(): void
18
    {
19
        $this->createDefaultFelixContainer();
20
    }
21
22
    /**
23
     * @dataProvider providerAssert
24
     */
25
    public function testAssert(array $input, bool $expected): void
26
    {
27
        $assertions = [];
28
        foreach ($input as $value) {
29
            $internalAssertion = $this->createMock(NamedAssertion::class);
30
            $internalAssertion->expects(self::atMost(1))
31
                ->method('assert')
32
                ->willReturn($value);
33
34
            $assertions[] = $internalAssertion;
35
        }
36
37
        $assertion = new All(...$assertions);
38
39
        $acl = $this->createMock(Acl::class);
40
        self::assertSame($expected, $assertion->assert($acl));
41
    }
42
43
    public function providerAssert(): array
44
    {
45
        return [
46
            [[], true],
47
            [[true], true],
48
            [[true, true], true],
49
            [[true, false], false],
50
            [[false, true], false],
51
            [[false, false], false],
52
            [[false], false],
53
        ];
54
    }
55
56
    public function testGetName(): void
57
    {
58
        $assert1 = $this->createMock(NamedAssertion::class);
59
        $assert1->expects(self::once())
60
            ->method('getName')
61
            ->willReturn('assert1');
62
63
        $assert2 = $this->createMock(NamedAssertion::class);
64
        $assert2->expects(self::once())
65
            ->method('getName')
66
            ->willReturn('assert2');
67
68
        $assert = new All($assert1, $assert2);
69
        self::assertSame('assert1, et assert2', $assert->getName());
70
    }
71
}
72