-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModuleTest.php
More file actions
72 lines (58 loc) · 2.07 KB
/
ModuleTest.php
File metadata and controls
72 lines (58 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* This file is part of phpab/phpab-module. (https://github.com/phpab/phpab-module)
*
* @link https://github.com/phpab/phpab-module for the canonical source repository
* @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/)
* @license https://raw.githubusercontent.com/phpab/phpab-module/master/LICENSE MIT
*/
namespace PhpAbModuleTest;
use PhpAb\Engine\EngineInterface;
use PhpAbModule\Module;
use PHPUnit_Framework_TestCase;
use Zend\EventManager\EventManagerInterface;
use Zend\ModuleManager\ModuleEvent;
use Zend\ModuleManager\ModuleManager;
use Zend\ServiceManager\ServiceManager;
class ModuleTest extends PHPUnit_Framework_TestCase
{
public function testGetConfig()
{
// Arrange
$module = new Module();
// Act
$result = $module->getConfig();
// Assert
$this->assertInternalType('array', $result);
}
public function testInit()
{
// Arrange
$module = new Module();
$eventManager = $this->getMock(EventManagerInterface::class);
$moduleManager = $this->getMockBuilder(ModuleManager::class)->disableOriginalConstructor()->getMock();
$moduleManager->method('getEventManager')->willReturn($eventManager);
// Assert
$eventManager->expects($this->once())->method('attach');
// Act
$module->init($moduleManager);
}
public function testOnLoadModulesPost()
{
// Arrange
$module = new Module();
$moduleEvent = $this->getMock(ModuleEvent::class);
$engine = $this->getMockForAbstractClass(EngineInterface::class);
$serviceManager = $this->getMock(ServiceManager::class);
// Assert
$moduleEvent->expects($this->once())->method('getParam')->willReturn($serviceManager);
$serviceManager
->expects($this->once())
->method('get')
->with($this->equalTo('phpab.engine'))
->willReturn($engine);
$engine->expects($this->once())->method('start');
// Act
$module->onLoadModulesPost($moduleEvent);
}
}