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 PHPUnit_Framework_TestCase; |
23
|
|
|
use DoctrineORMModule\Yuml\YumlController; |
24
|
|
|
use DoctrineORMModule\Yuml\YumlControllerFactory; |
25
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
26
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
27
|
|
|
|
28
|
|
|
class YumlControllerFactoryTest extends PHPUnit_Framework_TestCase |
29
|
|
|
{ |
30
|
|
|
public function testCreateService() |
31
|
|
|
{ |
32
|
|
|
$config = [ |
33
|
|
|
'zenddevelopertools' => [ |
34
|
|
|
'toolbar' => [ |
35
|
|
|
'enabled' => true, |
36
|
|
|
], |
37
|
|
|
], |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
41
|
|
|
->getMock(); |
42
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
43
|
|
|
->disableOriginalConstructor() |
44
|
|
|
->getMock(); |
45
|
|
|
|
46
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
47
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
48
|
|
|
|
49
|
|
|
$factory = new YumlControllerFactory(); |
50
|
|
|
$controller = $factory->createService($pluginManager); |
51
|
|
|
|
52
|
|
|
$this->assertInstanceOf(YumlController::class, $controller); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testCreateServiceWithNotEnabledToolbar() |
56
|
|
|
{ |
57
|
|
|
$config = [ |
58
|
|
|
'zenddevelopertools' => [ |
59
|
|
|
'toolbar' => [ |
60
|
|
|
'enabled' => false, |
61
|
|
|
], |
62
|
|
|
], |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
66
|
|
|
->getMock(); |
67
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
68
|
|
|
->disableOriginalConstructor() |
69
|
|
|
->getMock(); |
70
|
|
|
|
71
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
72
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
73
|
|
|
|
74
|
|
|
$factory = new YumlControllerFactory(); |
75
|
|
|
|
76
|
|
|
$this->expectException(\Zend\ServiceManager\Exception\ServiceNotFoundException::class); |
77
|
|
|
$factory->createService($pluginManager); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function testCreateServiceWithNoConfigKey() |
81
|
|
|
{ |
82
|
|
|
$config = [ |
83
|
|
|
'zenddevelopertools' => [], |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
$serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class) |
87
|
|
|
->getMock(); |
88
|
|
|
$pluginManager = $this->getMockBuilder(AbstractPluginManager::class) |
89
|
|
|
->disableOriginalConstructor() |
90
|
|
|
->getMock(); |
91
|
|
|
|
92
|
|
|
$serviceLocator->expects($this->once())->method('get')->with('config')->willReturn($config); |
93
|
|
|
$pluginManager->expects($this->once())->method('getServiceLocator')->willReturn($serviceLocator); |
94
|
|
|
|
95
|
|
|
$factory = new YumlControllerFactory(); |
96
|
|
|
|
97
|
|
|
$this->expectException(\Zend\ServiceManager\Exception\ServiceNotFoundException::class); |
98
|
|
|
$factory->createService($pluginManager); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|