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
Fixes #177 - MVC InputFilterPluginManager missing InputFilterAbstractFactory config #181
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ac0e6d
Adds missing unit tests for Module class
froschdesign d9e295b
Adds input-filter configruation to Module class
froschdesign e638cc6
Removes spaces between brackets of function declaration
froschdesign 8a4c7b3
Updates links to licence in Doc-Blocks
froschdesign 10d52d8
Improves unit tests for module class to ensure extensions
froschdesign 4af654a
Fixes tags for website reference and license in DocBlocks
froschdesign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?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\InputFilterPluginManagerFactory; | ||
use Zend\InputFilter\Module; | ||
|
||
class ModuleTest extends TestCase | ||
{ | ||
/** @var Module */ | ||
private $module; | ||
|
||
public 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')->willReturn( | ||
$serviceListener->reveal() | ||
); | ||
|
||
// Event | ||
$event = $this->prophesize(TestAsset\ModuleEventInterface::class); | ||
$event->getParam('ServiceManager')->willReturn($container->reveal()); | ||
|
||
// Module manager | ||
$moduleManager = $this->prophesize( | ||
TestAsset\ModuleManagerInterface::class | ||
); | ||
$moduleManager->getEvent()->willReturn($event->reveal()); | ||
|
||
$this->assertNull($this->module->init($moduleManager->reveal())); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* @link 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 | ||
*/ | ||
|
||
namespace ZendTest\InputFilter\TestAsset; | ||
|
||
/** | ||
* Mock interface to use when testing Module::init | ||
* | ||
* Mimics Zend\ModuleManager\ModuleEvent methods called. | ||
*/ | ||
interface ModuleEventInterface | ||
{ | ||
public function getParam($name, $default = null); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* @link 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 | ||
*/ | ||
|
||
namespace ZendTest\InputFilter\TestAsset; | ||
|
||
interface ModuleManagerInterface | ||
{ | ||
public function getEvent(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* @link 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 | ||
*/ | ||
|
||
namespace ZendTest\InputFilter\TestAsset; | ||
|
||
/** | ||
* Stub interfact to mock when testing Module::init. | ||
* | ||
* Mimics method that will be called on ServiceListener. | ||
*/ | ||
interface ServiceListenerInterface | ||
{ | ||
/** | ||
* @param string $pluginManagerService | ||
* @param string $configKey | ||
* @param string $interface | ||
* @param string $method | ||
*/ | ||
public function addServiceManager( | ||
$pluginManagerService, | ||
$configKey, | ||
$interface, | ||
$method | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.