Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 35e1fea

Browse files
committed
Merge branch 'hotfix/181' into develop
Forward port #181
2 parents 5feeeff + dc81b76 commit 35e1fea

File tree

6 files changed

+164
-3
lines changed

6 files changed

+164
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ All notable changes to this project will be documented in this file, in reverse
4444

4545
### Fixed
4646

47+
- [#181](https://github.com/zendframework/zend-inputfilter/pull/181) fixes
48+
missing abstract service factory registration in `Module` as per the
49+
[latest documentation](https://docs.zendframework.com/zend-inputfilter/specs/#setup).
50+
In particular, it ensures that the `InputFilterAbstractFactory` is registered
51+
under the `input_filters` configuration.
52+
4753
- [#180](https://github.com/zendframework/zend-inputfilter/pull/180) fixes
4854
attaching validators on creation of InputFilter - `priority` value is now used.
4955

src/Module.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* @link http://github.com/zendframework/zend-inputfilter for the canonical source repository
4-
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5-
* @license http://framework.zend.com/license/new-bsd New BSD License
3+
* @see https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace Zend\InputFilter;
@@ -18,6 +18,7 @@ public function getConfig()
1818

1919
return [
2020
'service_manager' => $provider->getDependencyConfig(),
21+
'input_filters' => $provider->getInputFilterConfig(),
2122
];
2223
}
2324

test/ModuleTest.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\InputFilter;
9+
10+
use Interop\Container\ContainerInterface;
11+
use PHPUnit\Framework\TestCase;
12+
use Zend\InputFilter\InputFilterAbstractServiceFactory;
13+
use Zend\InputFilter\InputFilterPluginManager;
14+
use Zend\InputFilter\Module;
15+
16+
class ModuleTest extends TestCase
17+
{
18+
/** @var Module */
19+
private $module;
20+
21+
protected function setUp()
22+
{
23+
$this->module = new Module();
24+
}
25+
26+
public function testGetConfigMethodShouldReturnExpectedKeys()
27+
{
28+
$config = $this->module->getConfig();
29+
30+
$this->assertInternalType('array', $config);
31+
32+
// Service manager
33+
$this->assertArrayHasKey('service_manager', $config);
34+
35+
// Input filters
36+
$this->assertArrayHasKey('input_filters', $config);
37+
}
38+
39+
public function testServiceManagerConfigShouldContainInputFilterManager()
40+
{
41+
$config = $this->module->getConfig();
42+
43+
$this->assertArrayHasKey(
44+
InputFilterPluginManager::class,
45+
$config['service_manager']['factories']
46+
);
47+
}
48+
49+
public function testServiceManagerConfigShouldContainAliasForInputFilterManager()
50+
{
51+
$config = $this->module->getConfig();
52+
53+
$this->assertArrayHasKey(
54+
'InputFilterManager',
55+
$config['service_manager']['aliases']
56+
);
57+
}
58+
59+
public function testInputFilterConfigShouldContainAbstractServiceFactory()
60+
{
61+
$config = $this->module->getConfig();
62+
63+
$this->assertContains(
64+
InputFilterAbstractServiceFactory::class,
65+
$config['input_filters']['abstract_factories']
66+
);
67+
}
68+
69+
public function testInitMethodShouldRegisterPluginManagerSpecificationWithServiceListener()
70+
{
71+
// Service listener
72+
$serviceListener = $this->prophesize(TestAsset\ServiceListenerInterface::class);
73+
$serviceListener->addServiceManager(
74+
'InputFilterManager',
75+
'input_filters',
76+
'Zend\ModuleManager\Feature\InputFilterProviderInterface',
77+
'getInputFilterConfig'
78+
)->shouldBeCalled();
79+
80+
// Container
81+
$container = $this->prophesize(ContainerInterface::class);
82+
$container->get('ServiceListener')->will([$serviceListener, 'reveal']);
83+
84+
// Event
85+
$event = $this->prophesize(TestAsset\ModuleEventInterface::class);
86+
$event->getParam('ServiceManager')->will([$container, 'reveal']);
87+
88+
// Module manager
89+
$moduleManager = $this->prophesize(TestAsset\ModuleManagerInterface::class);
90+
$moduleManager->getEvent()->will([$event, 'reveal']);
91+
92+
$this->assertNull($this->module->init($moduleManager->reveal()));
93+
}
94+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @link https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md
6+
*/
7+
8+
namespace ZendTest\InputFilter\TestAsset;
9+
10+
/**
11+
* Mock interface to use when testing Module::init
12+
*
13+
* Mimics Zend\ModuleManager\ModuleEvent methods called.
14+
*/
15+
interface ModuleEventInterface
16+
{
17+
public function getParam($name, $default = null);
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* @link https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md
6+
*/
7+
8+
namespace ZendTest\InputFilter\TestAsset;
9+
10+
interface ModuleManagerInterface
11+
{
12+
public function getEvent();
13+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* @link https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md
6+
*/
7+
8+
namespace ZendTest\InputFilter\TestAsset;
9+
10+
/**
11+
* Stub interfact to mock when testing Module::init.
12+
*
13+
* Mimics method that will be called on ServiceListener.
14+
*/
15+
interface ServiceListenerInterface
16+
{
17+
/**
18+
* @param string $pluginManagerService
19+
* @param string $configKey
20+
* @param string $interface
21+
* @param string $method
22+
*/
23+
public function addServiceManager(
24+
$pluginManagerService,
25+
$configKey,
26+
$interface,
27+
$method
28+
);
29+
}

0 commit comments

Comments
 (0)