MappingDriverFactoryLazyLoadProxyTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldCreatedMappingDriver() 0 32 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\MappingDriverFactoryLazyLoadProxy;
18
use Symfony\Component\DependencyInjection\ContainerInterface;
19
20
final class MappingDriverFactoryLazyLoadProxyTest extends TestCase
21
{
22
23
    /**
24
     * @test
25
     */
26
    public function shouldCreatedMappingDriver()
27
    {
28
        /** @var MappingDriver $mappingDriver */
29
        $mappingDriver = $this->createMock(MappingDriver::class);
30
31
        /** @var ContainerInterface $container */
32
        $container = $this->createMock(ContainerInterface::class);
33
34
        /** @var MappingDriverFactoryInterface $service */
35
        $service = $this->createMock(MappingDriverFactoryInterface::class);
36
37
        $container->method('get')->will($this->returnValueMap([
0 ignored issues
show
Bug introduced by
The method method() does not exist on Symfony\Component\Depend...tion\ContainerInterface. ( Ignorable by Annotation )

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

37
        $container->/** @scrutinizer ignore-call */ 
38
                    method('get')->will($this->returnValueMap([

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...
38
            ['some_service', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $service],
39
        ]));
40
41
        $container->method('has')->will($this->returnValueMap([
42
            ['some_service', true],
43
        ]));
44
45
        /** @var MappingDriverInterface $expectedMappingDriver */
46
        $expectedMappingDriver = $this->createMock(MappingDriverInterface::class);
47
48
        $service->expects($this->once())->method('createRDMMappingDriver')->willReturn(
0 ignored issues
show
Bug introduced by
The method expects() 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

48
        $service->/** @scrutinizer ignore-call */ 
49
                  expects($this->once())->method('createRDMMappingDriver')->willReturn(

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...
49
            $expectedMappingDriver
50
        );
51
52
        $driverFactory = new MappingDriverFactoryLazyLoadProxy($container, "some_service");
53
54
        /** @var MappingDriverInterface $actualMappingDriver */
55
        $actualMappingDriver = $driverFactory->createRDMMappingDriver($mappingDriver);
56
57
        $this->assertSame($expectedMappingDriver, $actualMappingDriver);
58
    }
59
60
}
61