Skip to content

Commit f30a767

Browse files
committed
Merge branch 'hotfix/2683'
Close zendframework#2683
2 parents a3963a7 + 08c44a5 commit f30a767

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

library/Zend/ServiceManager/ServiceManager.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,11 @@ public function setShared($name, $isShared)
385385
{
386386
$cName = $this->canonicalizeName($name);
387387

388-
if (!isset($this->invokableClasses[$cName]) && !isset($this->factories[$cName])) {
388+
if (
389+
!isset($this->invokableClasses[$cName])
390+
&& !isset($this->factories[$cName])
391+
&& !$this->canCreateFromAbstractFactory($cName, $name)
392+
) {
389393
throw new Exception\ServiceNotFoundException(sprintf(
390394
'%s: A service by the name "%s" was not found and could not be marked as shared',
391395
__METHOD__,

tests/ZendTest/ServiceManager/ServiceManagerTest.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public function testAddInitializerThrowsExceptionOnInvalidInitializer()
141141
$this->serviceManager->addInitializer(5);
142142
}
143143

144-
145144
/**
146145
* @covers Zend\ServiceManager\ServiceManager::setService
147146
*/
@@ -161,6 +160,16 @@ public function testSetShared()
161160
$this->assertSame($this->serviceManager, $ret);
162161
}
163162

163+
/**
164+
* @covers Zend\ServiceManager\ServiceManager::setShared
165+
*/
166+
public function testSetSharedAbstractFactory()
167+
{
168+
$this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');
169+
$ret = $this->serviceManager->setShared('foo', false);
170+
$this->assertSame($this->serviceManager, $ret);
171+
}
172+
164173
/**
165174
* @covers Zend\ServiceManager\ServiceManager::setShared
166175
*/
@@ -197,7 +206,6 @@ public function testGetThrowsExceptionOnUnknownService()
197206
$this->assertEquals('bar', $this->serviceManager->get('foo'));
198207
}
199208

200-
201209
/**
202210
* @covers Zend\ServiceManager\ServiceManager::get
203211
*/
@@ -536,6 +544,7 @@ public function testShouldRaiseExceptionIfInitializerClassIsNotAnInitializerInte
536544
public function duplicateService()
537545
{
538546
$self = $this;
547+
539548
return array(
540549
array(
541550
'setFactory',

0 commit comments

Comments
 (0)