diff --git a/src/AbstractConfigFactory.php b/src/AbstractConfigFactory.php index 6bb63b4..b9c8766 100644 --- a/src/AbstractConfigFactory.php +++ b/src/AbstractConfigFactory.php @@ -84,7 +84,7 @@ public function createServiceWithName(ServiceManager\ServiceLocatorInterface $se $config = $serviceLocator->get('Config'); $this->configs[$requestedName] = $this->configs[$key] = $config[$key]; - return $config; + return $config[$key]; } /** diff --git a/test/AbstractConfigFactoryTest.php b/test/AbstractConfigFactoryTest.php index fdc8db1..397e9ee 100644 --- a/test/AbstractConfigFactoryTest.php +++ b/test/AbstractConfigFactoryTest.php @@ -20,6 +20,11 @@ */ class AbstractConfigFactoryTest extends \PHPUnit_Framework_TestCase { + /** + * @var array + */ + protected $config; + /** * @var \Zend\Mvc\Application */ @@ -35,7 +40,7 @@ class AbstractConfigFactoryTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $config = array( + $this->config = array( 'MyModule' => array( 'foo' => array( 'bar' @@ -56,7 +61,7 @@ public function setUp() )) ); - $sm->setService('Config', $config); + $sm->setService('Config', $this->config); } /** @@ -131,4 +136,17 @@ public function testCreateService() $this->assertInternalType('array', $serviceLocator->get('phly-blog-config')); $this->assertInternalType('array', $serviceLocator->get('config-phly-blog')); } + + /** + * @depends testCreateService + * + * @group 7142 + * @group 7144 + */ + public function testCreateServiceWithRequestedConfigKey() + { + $serviceLocator = $this->serviceManager; + $this->assertSame($this->config['MyModule'], $serviceLocator->get('MyModule\Config')); + $this->assertSame($this->config['phly-blog'], $serviceLocator->get('phly-blog-config')); + } }