Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/allow-set-shared-for-abstract-factory-stuff' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Oct 5, 2012
2 parents a3963a7 + a9ad6db commit 08c44a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion library/Zend/ServiceManager/ServiceManager.php
Expand Up @@ -385,7 +385,11 @@ public function setShared($name, $isShared)
{
$cName = $this->canonicalizeName($name);

if (!isset($this->invokableClasses[$cName]) && !isset($this->factories[$cName])) {
if (
!isset($this->invokableClasses[$cName])
&& !isset($this->factories[$cName])
&& !$this->canCreateFromAbstractFactory($cName, $name)
) {
throw new Exception\ServiceNotFoundException(sprintf(
'%s: A service by the name "%s" was not found and could not be marked as shared',
__METHOD__,
Expand Down
13 changes: 11 additions & 2 deletions tests/ZendTest/ServiceManager/ServiceManagerTest.php
Expand Up @@ -141,7 +141,6 @@ public function testAddInitializerThrowsExceptionOnInvalidInitializer()
$this->serviceManager->addInitializer(5);
}


/**
* @covers Zend\ServiceManager\ServiceManager::setService
*/
Expand All @@ -161,6 +160,16 @@ public function testSetShared()
$this->assertSame($this->serviceManager, $ret);
}

/**
* @covers Zend\ServiceManager\ServiceManager::setShared
*/
public function testSetSharedAbstractFactory()
{
$this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');
$ret = $this->serviceManager->setShared('foo', false);
$this->assertSame($this->serviceManager, $ret);
}

/**
* @covers Zend\ServiceManager\ServiceManager::setShared
*/
Expand Down Expand Up @@ -197,7 +206,6 @@ public function testGetThrowsExceptionOnUnknownService()
$this->assertEquals('bar', $this->serviceManager->get('foo'));
}


/**
* @covers Zend\ServiceManager\ServiceManager::get
*/
Expand Down Expand Up @@ -536,6 +544,7 @@ public function testShouldRaiseExceptionIfInitializerClassIsNotAnInitializerInte
public function duplicateService()
{
$self = $this;

return array(
array(
'setFactory',
Expand Down

0 comments on commit 08c44a5

Please sign in to comment.