diff --git a/test/AbstractPluginManagerTest.php b/test/AbstractPluginManagerTest.php index 90b9676e..7957c5c9 100644 --- a/test/AbstractPluginManagerTest.php +++ b/test/AbstractPluginManagerTest.php @@ -17,7 +17,9 @@ use Zend\ServiceManager\Exception\RuntimeException; use Zend\ServiceManager\ServiceManager; use ZendTest\ServiceManager\TestAsset\FooPluginManager; +use ZendTest\ServiceManager\TestAsset\InvokableObject; use ZendTest\ServiceManager\TestAsset\MockSelfReturningDelegatorFactory; +use ZendTest\ServiceManager\TestAsset\V2v3PluginManager; class AbstractPluginManagerTest extends \PHPUnit_Framework_TestCase { @@ -333,4 +335,10 @@ public function testPassingArgumentsOtherThanNullConfigOrContainerAsFirstConstru $this->setExpectedException(InvalidArgumentException::class); new FooPluginManager($arg); } + + public function testV2v3PluginManager() + { + $pluginManager = new V2v3PluginManager(new ServiceManager()); + $this->assertInstanceOf(InvokableObject::class, $pluginManager->get('foo')); + } } diff --git a/test/TestAsset/V2v3PluginManager.php b/test/TestAsset/V2v3PluginManager.php new file mode 100644 index 00000000..3772742a --- /dev/null +++ b/test/TestAsset/V2v3PluginManager.php @@ -0,0 +1,51 @@ + InvokableObject::class, + ]; + + protected $factories = [ + InvokableObject::class => InvokableFactory::class, + // Legacy (v2) due to alias resolution + 'zendtestservicemanagertestassetinvokableobject' => InvokableFactory::class, + ]; + + protected $instanceOf = InvokableObject::class; + + + public function validate($plugin) + { + if ($plugin instanceof $this->instanceOf) { + return; + } + + throw new InvalidServiceException(sprintf( + "'%s' is not an instance of '%s'", + get_class($plugin), + $this->instanceOf + )); + } + + /** + * {@inheritDoc} + */ + public function validatePlugin($plugin) + { + $this->validate($plugin); + } +}