CachedMappingDriverFactoryTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\RDMBundle\Tests\Mapping\DriverFactories;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\RDMBundle\Mapping\DriverFactories\CachedMappingDriverFactory;
15
use Psr\Cache\CacheItemPoolInterface;
16
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface;
17
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
18
use Addiks\RDMBundle\Mapping\Drivers\CachedMappingDriver;
19
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface;
20
use Symfony\Component\DependencyInjection\ContainerInterface;
21
22
final class CachedMappingDriverFactoryTest extends TestCase
23
{
24
25
    /**
26
     * @var CachedMappingDriverFactory
27
     */
28
    private $driverFactory;
29
30
    /**
31
     * @var MappingDriverFactoryInterface
32
     */
33
    private $innerMappingDriverFactory;
34
35
    /**
36
     * @var CacheItemPoolInterface
37
     */
38
    private $cacheItemPool;
39
40
    /**
41
     * @var ContainerInterface
42
     */
43
    private $container;
44
45
    public function setUp(): void
46
    {
47
        $this->innerMappingDriverFactory = $this->createMock(MappingDriverFactoryInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Addiks...actoryInterface::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Addiks\RDMBundle\Mapping...gDriverFactoryInterface of property $innerMappingDriverFactory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
        $this->cacheItemPool = $this->createMock(CacheItemPoolInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Psr\Ca...emPoolInterface::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Psr\Cache\CacheItemPoolInterface of property $cacheItemPool.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
        $this->container = $this->createMock(ContainerInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Symfon...tainerInterface::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Symfony\Component\Depend...tion\ContainerInterface of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50
51
        $this->driverFactory = new CachedMappingDriverFactory(
52
            $this->container,
53
            $this->innerMappingDriverFactory,
54
            $this->cacheItemPool
55
        );
56
    }
57
58
    /**
59
     * @test
60
     */
61
    public function shouldCreatedCachedMappingDriver()
62
    {
63
        /** @var MappingDriver $mappingDriver */
64
        $mappingDriver = $this->createMock(MappingDriver::class);
65
66
        /** @var MappingDriverInterface $innerRdmMappingDriver */
67
        $innerRdmMappingDriver = $this->createMock(MappingDriverInterface::class);
68
69
        $this->innerMappingDriverFactory->method('createRDMMappingDriver')->willReturn($innerRdmMappingDriver);
0 ignored issues
show
Bug introduced by
The method method() does not exist on Addiks\RDMBundle\Mapping...gDriverFactoryInterface. ( Ignorable by Annotation )

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

69
        $this->innerMappingDriverFactory->/** @scrutinizer ignore-call */ 
70
                                          method('createRDMMappingDriver')->willReturn($innerRdmMappingDriver);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
71
        /** @var CachedMappingDriver $rdmMappingDriver */
72
        $rdmMappingDriver = $this->driverFactory->createRDMMappingDriver($mappingDriver);
73
74
        $this->assertInstanceOf(CachedMappingDriver::class, $rdmMappingDriver);
75
    }
76
77
}
78