Completed
Push — master ( 3d2cfc...12b419 )
by Alejandro
14s queued 12s
created

EnhancedPHPDriverTest::provideFuncStyle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Common\Doctrine\Mapping;
6
7
use Doctrine\Persistence\Mapping\ClassMetadata;
8
use Doctrine\Persistence\Mapping\Driver\FileLocator;
9
use PHPUnit\Framework\TestCase;
10
use Prophecy\Argument;
11
use Prophecy\Prophecy\ObjectProphecy;
12
use Shlinkio\Shlink\Common\Doctrine\Mapping\EnhancedPHPDriver;
13
14
class EnhancedPHPDriverTest extends TestCase
15
{
16
    private ObjectProphecy $loader;
17
    private ObjectProphecy $meta;
18
19
    public function setUp(): void
20
    {
21
        $this->loader = $this->prophesize(FileLocator::class);
22
        $this->loader->findMappingFile(Argument::any())->willReturn(
23
            __DIR__ . '/../../../test-resources/mapping/fake.mapping.php',
24
        );
25
        $this->meta = $this->prophesize(ClassMetadata::class);
26
    }
27
28
    /**
29
     * @test
30
     * @dataProvider provideFuncStyle
31
     */
32
    public function internalFunctionIsInvokedBasedOnFunctionalStyle(array $args, int $metaExpectedCalls): void
33
    {
34
        $metaMethod = $this->meta->getFieldNames();
35
36
        $driver = new EnhancedPHPDriver($this->loader->reveal(), [], ...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $loadMappingsUsingFunctionalStyle of Shlinkio\Shlink\Common\D...HPDriver::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $driver = new EnhancedPHPDriver($this->loader->reveal(), [], /** @scrutinizer ignore-type */ ...$args);
Loading history...
37
        $driver->loadMetadataForClass('', $this->meta->reveal());
38
39
        $metaMethod->shouldHaveBeenCalledTimes($metaExpectedCalls);
40
    }
41
42
    public function provideFuncStyle(): iterable
43
    {
44
        yield 'func style' => [[true], 1];
45
        yield 'no func style' => [[false], 0];
46
        yield 'default func style' => [[], 0];
47
    }
48
}
49