This repository was archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathModuleTest.php
94 lines (75 loc) · 2.89 KB
/
ModuleTest.php
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @see https://github.com/zendframework/zend-inputfilter for the canonical source repository
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md New BSD License
*/
namespace ZendTest\InputFilter;
use Interop\Container\ContainerInterface;
use PHPUnit\Framework\TestCase;
use Zend\InputFilter\InputFilterAbstractServiceFactory;
use Zend\InputFilter\InputFilterPluginManager;
use Zend\InputFilter\Module;
class ModuleTest extends TestCase
{
/** @var Module */
private $module;
protected function setUp()
{
$this->module = new Module();
}
public function testGetConfigMethodShouldReturnExpectedKeys()
{
$config = $this->module->getConfig();
$this->assertInternalType('array', $config);
// Service manager
$this->assertArrayHasKey('service_manager', $config);
// Input filters
$this->assertArrayHasKey('input_filters', $config);
}
public function testServiceManagerConfigShouldContainInputFilterManager()
{
$config = $this->module->getConfig();
$this->assertArrayHasKey(
InputFilterPluginManager::class,
$config['service_manager']['factories']
);
}
public function testServiceManagerConfigShouldContainAliasForInputFilterManager()
{
$config = $this->module->getConfig();
$this->assertArrayHasKey(
'InputFilterManager',
$config['service_manager']['aliases']
);
}
public function testInputFilterConfigShouldContainAbstractServiceFactory()
{
$config = $this->module->getConfig();
$this->assertContains(
InputFilterAbstractServiceFactory::class,
$config['input_filters']['abstract_factories']
);
}
public function testInitMethodShouldRegisterPluginManagerSpecificationWithServiceListener()
{
// Service listener
$serviceListener = $this->prophesize(TestAsset\ServiceListenerInterface::class);
$serviceListener->addServiceManager(
'InputFilterManager',
'input_filters',
'Zend\ModuleManager\Feature\InputFilterProviderInterface',
'getInputFilterConfig'
)->shouldBeCalled();
// Container
$container = $this->prophesize(ContainerInterface::class);
$container->get('ServiceListener')->will([$serviceListener, 'reveal']);
// Event
$event = $this->prophesize(TestAsset\ModuleEventInterface::class);
$event->getParam('ServiceManager')->will([$container, 'reveal']);
// Module manager
$moduleManager = $this->prophesize(TestAsset\ModuleManagerInterface::class);
$moduleManager->getEvent()->will([$event, 'reveal']);
$this->assertNull($this->module->init($moduleManager->reveal()));
}
}