Failed Conditions
Pull Request — master (#13)
by Adrien
14:06
created

AllTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A providerAssert() 0 10 1
A testAssert() 0 16 2
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 PHPUnit\Framework\TestCase;
11
12
class AllTest extends TestCase
13
{
14
    /**
15
     * @dataProvider providerAssert
16
     */
17
    public function testAssert(array $input, bool $expected): void
18
    {
19
        $assertions = [];
20
        foreach ($input as $value) {
21
            $internalAssertion = $this->createMock(NamedAssertion::class);
22
            $internalAssertion->expects(self::atMost(1))
23
                ->method('assert')
24
                ->willReturn($value);
25
26
            $assertions[] = $internalAssertion;
27
        }
28
29
        $assertion = new All(...$assertions);
30
31
        $acl = $this->createMock(Acl::class);
32
        self::assertSame($expected, $assertion->assert($acl));
33
    }
34
35
    public function providerAssert(): array
36
    {
37
        return [
38
            [[], true],
39
            [[true], true],
40
            [[true, true], true],
41
            [[true, false], false],
42
            [[false, true], false],
43
            [[false, false], false],
44
            [[false], false],
45
        ];
46
    }
47
48
    public function testGetName(): void
49
    {
50
        $assert1 = $this->createMock(NamedAssertion::class);
51
        $assert1->expects(self::once())
52
            ->method('getName')
53
            ->willReturn('assert1');
54
55
        $assert2 = $this->createMock(NamedAssertion::class);
56
        $assert2->expects(self::once())
57
            ->method('getName')
58
            ->willReturn('assert2');
59
60
        $assert = new All($assert1, $assert2);
61
        self::assertSame('assert1, et assert2', $assert->getName());
62
    }
63
}
64