Permalink
Browse files

add multiple delegator test for abtract plugin manager

  • Loading branch information...
1 parent bfab44b commit 8af2409b5cbc48a2bf5665ea440058bf877a84d9 @stefanotorresi committed Sep 27, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 tests/ZendTest/ServiceManager/AbstractPluginManagerTest.php
@@ -17,6 +17,7 @@
use ZendTest\ServiceManager\TestAsset\FooCounterAbstractFactory;
use ZendTest\ServiceManager\TestAsset\FooPluginManager;
+use ZendTest\ServiceManager\TestAsset\MockSelfReturningDelegatorFactory;
class AbstractPluginManagerTest extends \PHPUnit_Framework_TestCase
{
@@ -168,4 +169,27 @@ public function testSingleDelegatorUsage()
$this->assertSame($delegator, $pluginManager->get('foo-service'));
}
+
+ public function testMultipleDelegatorsUsage()
+ {
+ $pluginManager = $this->getMockForAbstractClass('Zend\ServiceManager\AbstractPluginManager');
+
+ $fooDelegator = new MockSelfReturningDelegatorFactory();
+ $barDelegator = new MockSelfReturningDelegatorFactory();
+
+ $pluginManager->addDelegator('foo-service', $fooDelegator);
+ $pluginManager->addDelegator('foo-service', $barDelegator);
+ $pluginManager->setInvokableClass('foo-service', 'stdClass');
+
+ $pluginManager->expects($this->once())
+ ->method('validatePlugin')
+ ->with($barDelegator);
+
+ $this->assertSame($barDelegator, $pluginManager->get('foo-service'));
+ $this->assertCount(1, $barDelegator->instances);
+ $this->assertCount(1, $fooDelegator->instances);
+ $this->assertInstanceOf('stdClass', array_shift($fooDelegator->instances));
+ $this->assertSame($fooDelegator, array_shift($barDelegator->instances));
+
+ }
}

0 comments on commit 8af2409

Please sign in to comment.