MappingDriverFactoryAggregateTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A shouldCreatedMappingDriver() 0 19 1
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\MappingDriverFactoryInterface;
15
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
16
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface;
17
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryAggregate;
18
19
final class MappingDriverFactoryAggregateTest extends TestCase
20
{
21
22
    /**
23
     * @var MappingDriverFactoryAggregate
24
     */
25
    private $driverFactory;
26
27
    /**
28
     * @var MappingDriverFactoryInterface
29
     */
30
    private $innerMappingDriverFactoryA;
31
32
    /**
33
     * @var MappingDriverFactoryInterface
34
     */
35
    private $innerMappingDriverFactoryB;
36
37
    /**
38
     * @var MappingDriverFactoryInterface
39
     */
40
    private $innerMappingDriverFactoryC;
41
42
    public function setUp(): void
43
    {
44
        $this->innerMappingDriverFactoryA = $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 $innerMappingDriverFactoryA.

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...
45
        $this->innerMappingDriverFactoryB = $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 $innerMappingDriverFactoryB.

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...
46
        $this->innerMappingDriverFactoryC = $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 $innerMappingDriverFactoryC.

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...
47
48
        $this->driverFactory = new MappingDriverFactoryAggregate([
49
            $this->innerMappingDriverFactoryA,
50
            $this->innerMappingDriverFactoryB,
51
            $this->innerMappingDriverFactoryC,
52
        ]);
53
    }
54
55
    /**
56
     * @test
57
     */
58
    public function shouldCreatedMappingDriver()
59
    {
60
        /** @var MappingDriver $mappingDriver */
61
        $mappingDriver = $this->createMock(MappingDriver::class);
62
63
        /** @var MappingDriverInterface $expectedRdmMappingDriver */
64
        $expectedRdmMappingDriver = $this->createMock(MappingDriverInterface::class);
65
66
        /** @var MappingDriverInterface $anotherRdmMappingDriver */
67
        $anotherRdmMappingDriver = $this->createMock(MappingDriverInterface::class);
68
69
        $this->innerMappingDriverFactoryA->method('createRDMMappingDriver')->willReturn(null);
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->innerMappingDriverFactoryA->/** @scrutinizer ignore-call */ 
70
                                           method('createRDMMappingDriver')->willReturn(null);

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
        $this->innerMappingDriverFactoryB->method('createRDMMappingDriver')->willReturn($expectedRdmMappingDriver);
71
        $this->innerMappingDriverFactoryC->method('createRDMMappingDriver')->willReturn($anotherRdmMappingDriver);
72
73
        /** @var RdmMappingDriverChain $actualRdmMappingDriver */
74
        $actualRdmMappingDriver = $this->driverFactory->createRDMMappingDriver($mappingDriver);
75
76
        $this->assertSame($expectedRdmMappingDriver, $actualRdmMappingDriver);
77
    }
78
79
}
80