Issues (7)

test/Doctrine/Mapping/EnhancedPHPDriverTest.php (1 issue)

Labels
Severity
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\PhpUnit\ProphecyTrait;
12
use Prophecy\Prophecy\ObjectProphecy;
13
use Shlinkio\Shlink\Common\Doctrine\Mapping\EnhancedPHPDriver;
14
15
class EnhancedPHPDriverTest extends TestCase
16
{
17
    use ProphecyTrait;
18
19
    private ObjectProphecy $loader;
20
    private ObjectProphecy $meta;
21
22
    public function setUp(): void
23
    {
24
        $this->loader = $this->prophesize(FileLocator::class);
25
        $this->loader->findMappingFile(Argument::any())->willReturn(
26
            __DIR__ . '/../../../test-resources/mapping/fake.mapping.php',
27
        );
28
        $this->meta = $this->prophesize(ClassMetadata::class);
29
    }
30
31
    /**
32
     * @test
33
     * @dataProvider provideFuncStyle
34
     */
35
    public function internalFunctionIsInvokedBasedOnFunctionalStyle(array $args, int $metaExpectedCalls): void
36
    {
37
        $metaMethod = $this->meta->getFieldNames();
38
39
        $driver = new EnhancedPHPDriver($this->loader->reveal(), [], ...$args);
0 ignored issues
show
$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

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