Skip to content

Commit

Permalink
hotfix/zendframework#7142: AbstractConfigFactory now returns requeste…
Browse files Browse the repository at this point in the history
…d config array instead of complete configuration array
  • Loading branch information
Eduard Posinitskii committed Jan 21, 2015
1 parent 7e704a7 commit 6bf29b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Config/AbstractConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down
20 changes: 18 additions & 2 deletions tests/ZendTest/Config/AbstractConfigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
class AbstractConfigFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var array
*/
protected $config;

/**
* @var \Zend\Mvc\Application
*/
Expand All @@ -35,7 +40,7 @@ class AbstractConfigFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
$config = array(
$this->config = array(
'MyModule' => array(
'foo' => array(
'bar'
Expand All @@ -56,7 +61,7 @@ public function setUp()
))
);

$sm->setService('Config', $config);
$sm->setService('Config', $this->config);
}

/**
Expand Down Expand Up @@ -131,4 +136,15 @@ public function testCreateService()
$this->assertInternalType('array', $serviceLocator->get('phly-blog-config'));
$this->assertInternalType('array', $serviceLocator->get('config-phly-blog'));
}

/**
* @depends testCreateService
* @return void
*/
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'));
}
}

0 comments on commit 6bf29b8

Please sign in to comment.