Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds unittest for this PR in specific component (mvc plugin manager) …

…implementation
  • Loading branch information...
commit 3ae21614c81c7ed4f29f51c5e522ffbef678b961 1 parent 5e971ef
@basz authored
View
23 tests/ZendTest/Mvc/Controller/Plugin/TestAsset/SamplePluginFactory.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
+
+namespace ZendTest\Mvc\Controller\Plugin\TestAsset;
+
+use Zend\Mvc\Controller\Plugin\AbstractPlugin;
+use Zend\ServiceManager\FactoryInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+class SamplePluginFactory implements FactoryInterface
+{
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ return new SamplePlugin();
+ }
+}
View
30 tests/ZendTest/Mvc/Controller/Plugin/TestAsset/SamplePluginWithConstructorFactory.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
+
+namespace ZendTest\Mvc\Controller\Plugin\TestAsset;
+
+use Zend\Mvc\Controller\Plugin\AbstractPlugin;
+use Zend\ServiceManager\FactoryInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+class SamplePluginWithConstructorFactory implements FactoryInterface
+{
+ protected $options;
+
+ public function __construct($options)
+ {
+ $this->options = $options;
+ }
+
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ return new SamplePluginWithConstructor($this->options);
+ }
+}
View
18 tests/ZendTest/Mvc/Controller/PluginManagerTest.php
@@ -71,4 +71,22 @@ public function testGetWithConstrutorAndOptions()
$plugin = $pluginManager->get('samplePlugin', 'foo');
$this->assertEquals($plugin->getBar(), 'foo');
}
+
+ public function testCanCreateByFactory()
+ {
+ $pluginManager = new PluginManager;
+ $pluginManager->setFactory('samplePlugin', 'ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginFactory');
+ $plugin = $pluginManager->get('samplePlugin');
+ $this->assertInstanceOf('\ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePlugin', $plugin);
+ }
+
+ public function testCanCreateByFactoryWithConstrutor()
+ {
+ $pluginManager = new PluginManager;
+ $pluginManager->setFactory('samplePlugin', 'ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginWithConstructorFactory');
+ $plugin = $pluginManager->get('samplePlugin', 'foo');
+ $this->assertInstanceOf('\ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginWithConstructor', $plugin);
+ $this->assertEquals($plugin->getBar(), 'foo');
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.