From 7dc6e9f214c7c8afc690f7b6e00125bd77bf5803 Mon Sep 17 00:00:00 2001 From: Norbert Hanauer Date: Tue, 24 Oct 2017 15:18:03 +0200 Subject: [PATCH 1/4] Add ConfigProvider.php and ConfigProviderTest --- src/TwbBundle/ConfigProvider.php | 78 ++++++++++++++++++++++ tests/TwbBundleTest/ConfigProviderTest.php | 42 ++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 src/TwbBundle/ConfigProvider.php create mode 100644 tests/TwbBundleTest/ConfigProviderTest.php diff --git a/src/TwbBundle/ConfigProvider.php b/src/TwbBundle/ConfigProvider.php new file mode 100644 index 0000000..e122da2 --- /dev/null +++ b/src/TwbBundle/ConfigProvider.php @@ -0,0 +1,78 @@ +moduleConfig = require self::MODULE_CONFIG_PATH; + + return [ + 'twbbundle' => $this->getTwbBundleOptions(), + 'dependencies' => $this->getDependencies(), + 'view_helpers' => $this->getViewHelpers() + ]; + } + + /** + * Returns twb bundle options + * + * @return array + */ + protected function getTwbBundleOptions() + { + return array_key_exists('twbbundle', $this->moduleConfig) ? $this->moduleConfig['twbbundle'] : []; + } + + /** + * Returns dependencies (former server_manager) + * + * @return array + */ + protected function getDependencies() + { + return array_key_exists('service_manager', $this->moduleConfig) ? $this->moduleConfig['service_manager'] : []; + } + + /** + * Returns view helpers + * + * @return array + */ + protected function getViewHelpers() + { + return array_key_exists('view_helpers', $this->moduleConfig) ? $this->moduleConfig['view_helpers'] : []; + } +} diff --git a/tests/TwbBundleTest/ConfigProviderTest.php b/tests/TwbBundleTest/ConfigProviderTest.php new file mode 100644 index 0000000..3f421ac --- /dev/null +++ b/tests/TwbBundleTest/ConfigProviderTest.php @@ -0,0 +1,42 @@ +configProvider = new ConfigProvider(); + } + + /** + * Tests valid return values + */ + public function testInvokeReturnValues() + { + $config = $this->configProvider->__invoke(); + + $this->assertArrayHasKey('twbbundle', $config); + $this->assertArrayHasKey('dependencies', $config); + $this->assertArrayHasKey('view_helpers', $config); + + $this->assertNotEmpty($config['twbbundle']); + $this->assertNotEmpty($config['dependencies']); + $this->assertNotEmpty($config['view_helpers']); + } +} From abab8b3143caea9ea213c3cbf913e406b0e199e5 Mon Sep 17 00:00:00 2001 From: Norbert Hanauer Date: Tue, 24 Oct 2017 15:24:00 +0200 Subject: [PATCH 2/4] Adjust alignments --- tests/TwbBundleTest/ConfigProviderTest.php | 85 +++++++++++----------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/tests/TwbBundleTest/ConfigProviderTest.php b/tests/TwbBundleTest/ConfigProviderTest.php index 3f421ac..d5c858e 100644 --- a/tests/TwbBundleTest/ConfigProviderTest.php +++ b/tests/TwbBundleTest/ConfigProviderTest.php @@ -1,42 +1,43 @@ -configProvider = new ConfigProvider(); - } - - /** - * Tests valid return values - */ - public function testInvokeReturnValues() - { - $config = $this->configProvider->__invoke(); - - $this->assertArrayHasKey('twbbundle', $config); - $this->assertArrayHasKey('dependencies', $config); - $this->assertArrayHasKey('view_helpers', $config); - - $this->assertNotEmpty($config['twbbundle']); - $this->assertNotEmpty($config['dependencies']); - $this->assertNotEmpty($config['view_helpers']); - } -} +configProvider = new ConfigProvider(); + } + + /** + * Tests valid return values + */ + public function testInvokeReturnValues() + { + $config = $this->configProvider->__invoke(); + + $this->assertArrayHasKey('twbbundle', $config); + $this->assertArrayHasKey('dependencies', $config); + $this->assertArrayHasKey('view_helpers', $config); + + $this->assertNotEmpty($config['twbbundle']); + $this->assertNotEmpty($config['dependencies']); + $this->assertNotEmpty($config['view_helpers']); + } +} From 7685996b485557efca0e29bba77f18a6660656a0 Mon Sep 17 00:00:00 2001 From: Norbert Hanauer Date: Tue, 24 Oct 2017 15:26:15 +0200 Subject: [PATCH 3/4] Adjust aligments 2 --- tests/TwbBundleTest/ConfigProviderTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/TwbBundleTest/ConfigProviderTest.php b/tests/TwbBundleTest/ConfigProviderTest.php index d5c858e..fa27231 100644 --- a/tests/TwbBundleTest/ConfigProviderTest.php +++ b/tests/TwbBundleTest/ConfigProviderTest.php @@ -12,23 +12,23 @@ class ConfigProviderTest extends \PHPUnit_Framework_TestCase { /** * The zend-component config provider - * + * * @var \TwbBundle\ConfigProvider */ - protected $configProvider; + protected $configProvider; - /** - * @see \PHPUnit_Framework_TestCase::setUp() - */ - public function setUp() + /** + * @see \PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { - $this->configProvider = new ConfigProvider(); - } + $this->configProvider = new ConfigProvider(); + } /** * Tests valid return values */ - public function testInvokeReturnValues() + public function testInvokeReturnValues() { $config = $this->configProvider->__invoke(); From b3962a7bcd9cb3c2feccaf80336bb202cde384e9 Mon Sep 17 00:00:00 2001 From: Norbert Hanauer Date: Tue, 24 Oct 2017 16:16:49 +0200 Subject: [PATCH 4/4] Add zf config-provider namespace entry to composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index ffc7709..bf678c4 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,9 @@ "extra": { "branch-alias": { "dev-master": "1.0-dev" + }, + "zf": { + "config-provider": "TwbBundle\\ConfigProvider" } } }