1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace DoctrineORMModuleTest\Yuml; |
21
|
|
|
|
22
|
|
|
use DoctrineORMModule\Yuml\YumlController; |
23
|
|
|
use DoctrineORMModule\Yuml\YumlControllerFactory; |
24
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
25
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
26
|
|
|
|
27
|
|
|
class YumlControllerFactoryTest extends \PHPUnit_Framework_TestCase |
28
|
|
|
{ |
29
|
|
|
public function testCreateService() |
30
|
|
|
{ |
31
|
|
|
$config = [ |
32
|
|
|
'zenddevelopertools' => [ |
33
|
|
|
'toolbar' => [ |
34
|
|
|
'enabled' => true |
35
|
|
|
] |
36
|
|
|
] |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
40
|
|
|
->getMock(); |
41
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
42
|
|
|
->disableOriginalConstructor() |
43
|
|
|
->getMock(); |
44
|
|
|
|
45
|
|
|
$serviceLocator->expects(static::once())->method('get')->with('config')->willReturn($config); |
46
|
|
|
$pluginManager->expects(static::once())->method('getServiceLocator')->willReturn($serviceLocator); |
47
|
|
|
|
48
|
|
|
$factory = new YumlControllerFactory(); |
49
|
|
|
$controller = $factory->createService($pluginManager); |
50
|
|
|
|
51
|
|
|
static::assertInstanceOf(YumlController::class, $controller); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @expectedException \Zend\ServiceManager\Exception\ServiceNotFoundException |
56
|
|
|
*/ |
57
|
|
|
public function testCreateServiceWithNotEnabledToolbar() |
58
|
|
|
{ |
59
|
|
|
$config = [ |
60
|
|
|
'zenddevelopertools' => [ |
61
|
|
|
'toolbar' => [ |
62
|
|
|
'enabled' => false |
63
|
|
|
] |
64
|
|
|
] |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
68
|
|
|
->getMock(); |
69
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
70
|
|
|
->disableOriginalConstructor() |
71
|
|
|
->getMock(); |
72
|
|
|
|
73
|
|
|
$serviceLocator->expects(static::once())->method('get')->with('config')->willReturn($config); |
74
|
|
|
$pluginManager->expects(static::once())->method('getServiceLocator')->willReturn($serviceLocator); |
75
|
|
|
|
76
|
|
|
$factory = new YumlControllerFactory(); |
77
|
|
|
$controller = $factory->createService($pluginManager); |
78
|
|
|
|
79
|
|
|
static::assertInstanceOf(YumlController::class, $controller); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @expectedException \Zend\ServiceManager\Exception\ServiceNotFoundException |
84
|
|
|
*/ |
85
|
|
|
public function testCreateServiceWithNoConfigKey() |
86
|
|
|
{ |
87
|
|
|
$config = [ |
88
|
|
|
'zenddevelopertools' => [] |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
92
|
|
|
->getMock(); |
93
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
94
|
|
|
->disableOriginalConstructor() |
95
|
|
|
->getMock(); |
96
|
|
|
|
97
|
|
|
$serviceLocator->expects(static::once())->method('get')->with('config')->willReturn($config); |
98
|
|
|
$pluginManager->expects(static::once())->method('getServiceLocator')->willReturn($serviceLocator); |
99
|
|
|
|
100
|
|
|
$factory = new YumlControllerFactory(); |
101
|
|
|
$controller = $factory->createService($pluginManager); |
102
|
|
|
|
103
|
|
|
static::assertInstanceOf(YumlController::class, $controller); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|