File tree 2 files changed +16
-3
lines changed
library/Zend/ServiceManager
tests/ZendTest/ServiceManager
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -385,7 +385,11 @@ public function setShared($name, $isShared)
385
385
{
386
386
$ cName = $ this ->canonicalizeName ($ name );
387
387
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
+ ) {
389
393
throw new Exception \ServiceNotFoundException (sprintf (
390
394
'%s: A service by the name "%s" was not found and could not be marked as shared ' ,
391
395
__METHOD__ ,
Original file line number Diff line number Diff line change @@ -141,7 +141,6 @@ public function testAddInitializerThrowsExceptionOnInvalidInitializer()
141
141
$ this ->serviceManager ->addInitializer (5 );
142
142
}
143
143
144
-
145
144
/**
146
145
* @covers Zend\ServiceManager\ServiceManager::setService
147
146
*/
@@ -161,6 +160,16 @@ public function testSetShared()
161
160
$ this ->assertSame ($ this ->serviceManager , $ ret );
162
161
}
163
162
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
+
164
173
/**
165
174
* @covers Zend\ServiceManager\ServiceManager::setShared
166
175
*/
@@ -197,7 +206,6 @@ public function testGetThrowsExceptionOnUnknownService()
197
206
$ this ->assertEquals ('bar ' , $ this ->serviceManager ->get ('foo ' ));
198
207
}
199
208
200
-
201
209
/**
202
210
* @covers Zend\ServiceManager\ServiceManager::get
203
211
*/
@@ -536,6 +544,7 @@ public function testShouldRaiseExceptionIfInitializerClassIsNotAnInitializerInte
536
544
public function duplicateService ()
537
545
{
538
546
$ self = $ this ;
547
+
539
548
return array (
540
549
array (
541
550
'setFactory ' ,
You can’t perform that action at this time.
0 commit comments