Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/richardjennings/zf2 into ho…
Browse files Browse the repository at this point in the history
…tfix/3237
  • Loading branch information
weierophinney committed Dec 18, 2012
2 parents a5f5a79 + 7df22b4 commit 60a0760
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/ServiceManager/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,8 @@ protected function createFromAbstractFactory($canonicalName, $requestedName)
));
}
try {
$this->pendingAbstractFactoryRequests[get_class($abstractFactory)] = $requestedName;
if ($abstractFactory->canCreateServiceWithName($this, $canonicalName, $requestedName)) {
$this->pendingAbstractFactoryRequests[get_class($abstractFactory)] = $requestedName;
$instance = $this->createServiceViaCallback(
array($abstractFactory, 'createServiceWithName'),
$canonicalName,
Expand Down
13 changes: 13 additions & 0 deletions tests/ZendTest/ServiceManager/ServiceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,4 +654,17 @@ public function testCanGetAliasedServicesFromPeeringServiceManagers()

$this->assertSame($service, $this->serviceManager->get('alias-name'));
}

/**
* @covers Zend\ServiceManager\ServiceManager::get
*/
public function testDuplicateNewInstanceMultipleAbstractFactories()
{
$this->serviceManager->setAllowOverride(true);
$this->serviceManager->setShareByDefault(false);
$this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\BarAbstractFactory');
$this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');
$this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $this->serviceManager->get('bar'));
$this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $this->serviceManager->get('bar'));
}
}

0 comments on commit 60a0760

Please sign in to comment.