public function testCreateService() { $pm = new ControllerPluginManager(); $sm = new ServiceManager(); $sm->setService('AcMailer\\Service\\MailService', new MailServiceMock()); $pm->setServiceLocator($sm); $this->assertInstanceOf('AcMailer\\Controller\\Plugin\\SendMailPlugin', $this->factory->createService($pm)); }
protected function createControllerManager($config = []) { $pm = new ControllerPluginManager(); $sm = new ServiceManager(); $sm->setService('Config', $config); $pm->setServiceLocator($sm); return $pm; }
/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); $this->createMergedDocument = new CreateMergedDocument(); $pluginManager = new PluginManager(); $pluginManager->setServiceLocator($this->serviceManager); $this->createMergedDocument->setServiceLocator($pluginManager); }
public function testFactory() { $serviceManager = new ServiceManager(); $pluginManager = new PluginManager(); $pluginManager->setServiceLocator($serviceManager); $serviceManager->setService('ZfjRbac\\Service\\AuthorizationService', $this->getMock('ZfjRbac\\Service\\AuthorizationServiceInterface')); $factory = new IsGrantedPluginFactory(); $isGranted = $factory->createService($pluginManager); $this->assertInstanceOf('ZfjRbac\\Mvc\\Controller\\Plugin\\IsGranted', $isGranted); }
public function testIdentityFactoryCanInjectAuthenticationServiceIfInParentServiceManager() { $services = new ServiceManager(); $services->setInvokableClass('Zend\\Authentication\\AuthenticationService', 'Zend\\Authentication\\AuthenticationService'); $pluginManager = new PluginManager(); $pluginManager->setServiceLocator($services); $identity = $pluginManager->get('identity'); $expected = $services->get('Zend\\Authentication\\AuthenticationService'); $this->assertSame($expected, $identity->getAuthenticationService()); }
public function testFactory() { $serviceManager = new ServiceManager(); $serviceManager->setService(LayoutInterface::class, $this->layout); $serviceManager->setService(LayoutUpdaterInterface::class, $this->layoutUpdater); $serviceManager->setService(BlockPoolInterface::class, $this->blockPool); $controllerPluginManager = new PluginManager(); $controllerPluginManager->setServiceLocator($serviceManager); $factory = new LayoutManagerFactory(); $instance = $factory->createService($controllerPluginManager); $this->assertInstanceOf(LayoutManager::class, $instance); }
public function testFactory() { $serviceManager = new ServiceManager(); $serviceManager->setService('ConLayout\\Layout\\LayoutInterface', $this->layout); $serviceManager->setService('ConLayout\\Updater\\LayoutUpdaterInterface', $this->updater); $serviceManager->setService('ConLayout\\View\\Renderer\\BlockRenderer', $this->renderer); $controllerPluginManager = new PluginManager(); $controllerPluginManager->setServiceLocator($serviceManager); $factory = new LayoutManagerFactory(); $instance = $factory->createService($controllerPluginManager); $this->assertInstanceOf('ConLayout\\Controller\\Plugin\\LayoutManager', $instance); }
public function testCanDisplayListOfMessagesCustomisedByConfig() { $this->seedMessages(); $config = array( 'view_helper_config' => array( 'flashmessenger' => array( 'message_open_format' => '<div%s><ul><li>', 'message_separator_string' => '</li><li>', 'message_close_string' => '</li></ul></div>', ), ), ); $sm = new ServiceManager(); $sm->setService('Config', $config); $helperPluginManager = new HelperPluginManager(new Config(array( 'factories' => array( 'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory', ), ))); $controllerPluginManager = new PluginManager(new Config(array( 'invokables' => array( 'flashmessenger' => 'Zend\Mvc\Controller\Plugin\FlashMessenger', ), ))); $helperPluginManager->setServiceLocator($sm); $controllerPluginManager->setServiceLocator($sm); $sm->setService('ControllerPluginManager', $controllerPluginManager); $helper = $helperPluginManager->get('flashmessenger'); $displayInfoAssertion = '<div class="info"><ul><li>bar-info</li></ul></div>'; $displayInfo = $helper->render(PluginFlashMessenger::NAMESPACE_INFO); $this->assertEquals($displayInfoAssertion, $displayInfo); }
/** * @expectedException \Zend\ServiceManager\Exception\ServiceNotCreatedException */ public function testCreateServiceWithoutModelManager() { $this->pm->setServiceLocator($this->sm); $this->factory->createService($this->pm); }
public function testCanDisplayListOfCurrentMessagesCustomisedByConfigSeparator() { $this->seedCurrentMessages(); $config = array('view_helper_config' => array('flashmessenger' => array('message_open_format' => '<div><ul><li%s>', 'message_separator_string' => '</li><li%s>', 'message_close_string' => '</li></ul></div>'))); $sm = new ServiceManager(); $sm->setService('Config', $config); $helperPluginManager = new HelperPluginManager(new Config(array('factories' => array('flashmessenger' => 'Zend\\View\\Helper\\Service\\FlashMessengerFactory')))); $controllerPluginManager = new PluginManager(new Config(array('invokables' => array('flashmessenger' => 'Zend\\Mvc\\Controller\\Plugin\\FlashMessenger')))); $helperPluginManager->setServiceLocator($sm); $controllerPluginManager->setServiceLocator($sm); $sm->setService('ControllerPluginManager', $controllerPluginManager); $helper = $helperPluginManager->get('flashmessenger'); $displayInfoAssertion = '<div><ul><li class="foo-baz foo-bar">foo</li><li class="foo-baz foo-bar">bar</li></ul></div>'; $displayInfo = $helper->renderCurrent(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar')); $this->assertEquals($displayInfoAssertion, $displayInfo); }