|
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); |
|
|
|
|
|
|
24
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
|
|
|
|
|
|
25
|
|
|
->disableOriginalConstructor() |
|
26
|
|
|
->getMock(); |
|
27
|
|
|
|
|
28
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
|
|
|
|
|
|
29
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
$factory = new YumlControllerFactory(); |
|
32
|
|
|
$controller = $factory->createService($pluginManager); |
|
33
|
|
|
|
|
34
|
|
|
$this->assertInstanceOf(YumlController::class, $controller); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
48
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
|
|
|
|
|
|
49
|
|
|
->disableOriginalConstructor() |
|
50
|
|
|
->getMock(); |
|
51
|
|
|
|
|
52
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
|
|
|
|
|
|
53
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$factory = new YumlControllerFactory(); |
|
56
|
|
|
|
|
57
|
|
|
$this->expectException(\Laminas\ServiceManager\Exception\ServiceNotFoundException::class); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
68
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
|
|
|
|
|
|
69
|
|
|
->disableOriginalConstructor() |
|
70
|
|
|
->getMock(); |
|
71
|
|
|
|
|
72
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
|
|
|
|
|
|
73
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
|
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
$factory = new YumlControllerFactory(); |
|
76
|
|
|
|
|
77
|
|
|
$this->expectException(\Laminas\ServiceManager\Exception\ServiceNotFoundException::class); |
|
|
|
|
|
|
78
|
|
|
$factory->createService($pluginManager); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
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.