MappingXMLDriverFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 1
A shouldCreatedAnnotationMappingDriver() 0 11 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\MappingXMLDriverFactory;
15
use Addiks\RDMBundle\Mapping\Drivers\MappingXmlDriver;
16
use Doctrine\ORM\Mapping\Driver\XmlDriver;
17
use Doctrine\Persistence\Mapping\Driver\FileLocator;
18
use Symfony\Component\HttpKernel\KernelInterface;
19
use Symfony\Component\DependencyInjection\ContainerInterface;
20
21
final class MappingXMLDriverFactoryTest extends TestCase
22
{
23
24
    /**
25
     * @var MappingXMLDriverFactory
26
     */
27
    private $driverFactory;
28
29
    public function setUp(): void
30
    {
31
        /** @var ContainerInterface $serviceContainer */
32
        $serviceContainer = $this->createMock(ContainerInterface::class);
33
34
        /** @var KernelInterface $kernel */
35
        $kernel = $this->createMock(KernelInterface::class);
36
        $kernel->method('getContainer')->willReturn($serviceContainer);
0 ignored issues
show
Bug introduced by
The method method() does not exist on Symfony\Component\HttpKernel\KernelInterface. ( Ignorable by Annotation )

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

36
        $kernel->/** @scrutinizer ignore-call */ 
37
                 method('getContainer')->willReturn($serviceContainer);

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...
37
38
        $this->driverFactory = new MappingXMLDriverFactory(
39
            $kernel,
40
            "/some/schema/path.xsd"
41
        );
42
    }
43
44
    /**
45
     * @test
46
     */
47
    public function shouldCreatedAnnotationMappingDriver()
48
    {
49
        /** @var XmlDriver $mappingDriver */
50
        $mappingDriver = $this->createMock(XmlDriver::class);
51
52
        $mappingDriver->method('getLocator')->willReturn($this->createMock(FileLocator::class));
0 ignored issues
show
Bug introduced by
The method method() does not exist on Doctrine\ORM\Mapping\Driver\XmlDriver. ( Ignorable by Annotation )

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

52
        $mappingDriver->/** @scrutinizer ignore-call */ 
53
                        method('getLocator')->willReturn($this->createMock(FileLocator::class));

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...
53
54
        /** @var MappingXmlDriver $rdmMappingDriver */
55
        $rdmMappingDriver = $this->driverFactory->createRDMMappingDriver($mappingDriver);
56
57
        $this->assertInstanceOf(MappingXmlDriver::class, $rdmMappingDriver);
58
    }
59
60
}
61