YumlControllerFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 70
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateService() 0 23 1
A testCreateServiceWithNotEnabledToolbar() 0 23 1
A testCreateServiceWithNoConfigKey() 0 19 1
1
<?php
2
3
namespace DoctrineORMModuleTest\Yuml;
4
5
use PHPUnit\Framework\TestCase;
6
use DoctrineORMModule\Yuml\YumlController;
7
use DoctrineORMModule\Yuml\YumlControllerFactory;
8
use Laminas\ServiceManager\AbstractPluginManager;
9
use Laminas\ServiceManager\ServiceLocatorInterface;
10
11
class YumlControllerFactoryTest extends TestCase
12
{
13
    public function testCreateService()
14
    {
15
        $config = [
16
            'laminas-developer-tools' => [
17
                'toolbar' => [
18
                    'enabled' => true,
19
                ],
20
            ],
21
        ];
22
23
        $serviceLocator = $this->createMock(ServiceLocatorInterface::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $serviceLocator is correct as $this->createMock(\Lamin...ocatorInterface::class) (which targets PHPUnit\Framework\TestCase::createMock()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
24
        $pluginManager = $this->getMockBuilder(AbstractPluginManager::class)
0 ignored issues
show
Bug introduced by
The method disableOriginalConstructor cannot be called on $this->getMockBuilder(\L...ctPluginManager::class) (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
25
            ->disableOriginalConstructor()
26
            ->getMock();
27
28
        $serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
Bug introduced by
The method expects cannot be called on $serviceLocator (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
29
        $pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
30
31
        $factory = new YumlControllerFactory();
32
        $controller = $factory->createService($pluginManager);
33
34
        $this->assertInstanceOf(YumlController::class, $controller);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
35
    }
36
37
    public function testCreateServiceWithNotEnabledToolbar()
38
    {
39
        $config = [
40
            'laminas-developer-tools' => [
41
                'toolbar' => [
42
                    'enabled' => false,
43
                ],
44
            ],
45
        ];
46
47
        $serviceLocator = $this->createMock(ServiceLocatorInterface::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $serviceLocator is correct as $this->createMock(\Lamin...ocatorInterface::class) (which targets PHPUnit\Framework\TestCase::createMock()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
48
        $pluginManager = $this->getMockBuilder(AbstractPluginManager::class)
0 ignored issues
show
Bug introduced by
The method disableOriginalConstructor cannot be called on $this->getMockBuilder(\L...ctPluginManager::class) (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
49
            ->disableOriginalConstructor()
50
            ->getMock();
51
52
        $serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
Bug introduced by
The method expects cannot be called on $serviceLocator (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
53
        $pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
54
55
        $factory = new YumlControllerFactory();
56
57
        $this->expectException(\Laminas\ServiceManager\Exception\ServiceNotFoundException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
58
        $factory->createService($pluginManager);
59
    }
60
61
    public function testCreateServiceWithNoConfigKey()
62
    {
63
        $config = [
64
            'laminas-developer-tools' => [],
65
        ];
66
67
        $serviceLocator = $this->createMock(ServiceLocatorInterface::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $serviceLocator is correct as $this->createMock(\Lamin...ocatorInterface::class) (which targets PHPUnit\Framework\TestCase::createMock()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
68
        $pluginManager = $this->getMockBuilder(AbstractPluginManager::class)
0 ignored issues
show
Bug introduced by
The method disableOriginalConstructor cannot be called on $this->getMockBuilder(\L...ctPluginManager::class) (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
69
            ->disableOriginalConstructor()
70
            ->getMock();
71
72
        $serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
Bug introduced by
The method expects cannot be called on $serviceLocator (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
73
        $pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator);
0 ignored issues
show
Bug introduced by
The method once() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
74
75
        $factory = new YumlControllerFactory();
76
77
        $this->expectException(\Laminas\ServiceManager\Exception\ServiceNotFoundException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...lControllerFactoryTest>.

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...
78
        $factory->createService($pluginManager);
79
    }
80
}
81