diff --git a/CHANGELOG.md b/CHANGELOG.md index 831198f4..de0cd21a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,13 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 2.7.1 - TBD +## 2.7.1 - 2016-03-30 ### Added -- Nothing. +- [#41](https://github.com/zendframework/zend-i18n/pull/41) adds + `Zend\I18n\Module::init()`, which registers a specification for the translator + loader plugin manager with `Zend\ModuleManager\Listener\ServiceListener`. ### Deprecated diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bcff5816..e2d36766 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ diff --git a/phpunit.xml.travis b/phpunit.xml.travis index bcff5816..e2d36766 100644 --- a/phpunit.xml.travis +++ b/phpunit.xml.travis @@ -1,7 +1,7 @@ diff --git a/src/Module.php b/src/Module.php index 29b622ed..3d1b5651 100644 --- a/src/Module.php +++ b/src/Module.php @@ -24,4 +24,23 @@ public function getConfig() 'view_helpers' => $provider->getViewHelperConfig(), ]; } + + /** + * Register a specification for the TranslatorPluginManager with the ServiceListener. + * + * @param \Zend\ModuleManager\ModuleEvent + * @return void + */ + public function init($event) + { + $container = $event->getParam('ServiceManager'); + $serviceListener = $container->get('ServiceListener'); + + $serviceListener->addServiceManager( + 'TranslatorPluginManager', + 'translator_plugins', + 'Zend\ModuleManager\Feature\TranslatorPluginProviderInterface', + 'getTranslatorPluginConfig' + ); + } } diff --git a/test/ModuleTest.php b/test/ModuleTest.php new file mode 100644 index 00000000..bd40e2a2 --- /dev/null +++ b/test/ModuleTest.php @@ -0,0 +1,49 @@ +module = new Module(); + } + + public function testConfigReturnsExpectedKeys() + { + $config = $this->module->getConfig(); + $this->assertInternalType('array', $config); + $this->assertArrayHasKey('filters', $config); + $this->assertArrayHasKey('service_manager', $config); + $this->assertArrayHasKey('validators', $config); + $this->assertArrayHasKey('view_helpers', $config); + } + + public function testInitRegistersPluginManagerSpecificationWithServiceListener() + { + $serviceListener = $this->prophesize(TestAsset\ServiceListenerInterface::class); + $serviceListener->addServiceManager( + 'TranslatorPluginManager', + 'translator_plugins', + 'Zend\ModuleManager\Feature\TranslatorPluginProviderInterface', + 'getTranslatorPluginConfig' + )->shouldBeCalled(); + + $container = $this->prophesize(ContainerInterface::class); + $container->get('ServiceListener')->willReturn($serviceListener->reveal()); + + $event = $this->prophesize(TestAsset\ModuleEventInterface::class); + $event->getParam('ServiceManager')->willReturn($container->reveal()); + + $this->assertNull($this->module->init($event->reveal())); + } +} diff --git a/test/TestAsset/ModuleEventInterface.php b/test/TestAsset/ModuleEventInterface.php new file mode 100644 index 00000000..cef63285 --- /dev/null +++ b/test/TestAsset/ModuleEventInterface.php @@ -0,0 +1,18 @@ +