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

OneTest::testGetName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9332
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\NamedAssertion;
9
use Ecodev\Felix\Acl\Assertion\One;
1 ignored issue
show
Bug introduced by
The type Ecodev\Felix\Acl\Assertion\One 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...
10
use PHPUnit\Framework\TestCase;
11
12
class OneTest 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 One(...$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
            [[], false],
39
            [[true], true],
40
            [[true, true], true],
41
            [[true, false], true],
42
            [[false, true], true],
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 One($assert1, $assert2);
61
        self::assertSame('assert1, ou assert2', $assert->getName());
62
    }
63
}
64