/** * @covers Eye4web\ZfcUser\Pm\Factory\Options\ModuleOptionsFactory::createService */ public function testCreateServiceWithConfig() { $config = ['eye4web' => ['zfc-user' => ['pm' => []]]]; $this->serviceLocator->expects($this->at(0))->method('get')->with('Config')->willReturn($config); $result = $this->factory->createService($this->serviceLocator); $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptionsInterface', $result); }
public function setUp() { $this->serviceLocatorMock = $this->getMockForAbstractClass('Zend\\ServiceManager\\ServiceLocatorInterface', ['get']); $this->serviceLocatorMock->expects($this->exactly(2))->method('get')->with('config')->will($this->returnValue(['navInstallerTitles' => ['install' => 'SomeTitle'], 'navInstaller' => [['key1' => 'value1'], ['key2' => 'value2'], ['nav' => 'abc', 'key3' => 'value3'], ['nav' => ''], ['nav' => false], ['main' => 'abc', 'key3' => 'value3'], ['main' => ''], ['main' => false]]])); $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false); $this->navigation = new Navigation($this->serviceLocatorMock, $this->deploymentConfig); }
/** * @covers Eye4web\ZfcUser\Settings\Factory\Service\UserSettingsServiceFactory::createService */ public function testCreateService() { $userSettingMapper = $this->getMockBuilder('Eye4web\\ZfcUser\\Settings\\Mapper\\DoctrineORM\\UserSettingMapper')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Settings\\Mapper\\DoctrineORM\\UserSettingMapper')->willReturn($userSettingMapper); $result = $this->factory->createService($this->serviceLocator); $this->assertInstanceOf('Eye4web\\ZfcUser\\Settings\\Service\\UserSettingsService', $result); }
public function testGet() { $this->locator->expects($this->once())->method('get')->with(InitParamListener::BOOTSTRAP_PARAM)->willReturn([]); $objectManager = $this->object->get(); $this->assertInstanceOf('Magento\\Framework\\ObjectManagerInterface', $objectManager); $this->assertSame($objectManager, $this->object->get()); }
/** * @covers \BjyAuthorize\Provider\Role\ZendDb::getRoles */ public function testGetRolesWithInheritance() { $this->tableGateway->expects($this->any())->method('selectWith')->will($this->returnValue(array(array('id' => 1, 'role_id' => 'guest', 'is_default' => 1, 'parent_id' => null), array('id' => 2, 'role_id' => 'user', 'is_default' => 0, 'parent_id' => 1)))); $this->serviceLocator->expects($this->any())->method('get')->will($this->returnValue($this->tableGateway)); $provider = new ZendDb(array(), $this->serviceLocator); $this->assertEquals($provider->getRoles(), array(new Role('guest'), new Role('user', 'guest'))); }
public function testCreateService() { $aclmock = $this->getMock('LearnZF2Acl\\Model\\Acl'); $this->serviceLocator->expects($this->at(0))->method('get')->with('aclmodel')->willReturn($aclmock); $result = $this->factory->createService($this->controllerManager); $this->assertInstanceOf('LearnZF2Acl\\Controller\\AclController', $result); }
public function setUp() { $this->newEntry = $this->getMockBuilder(stdClass::class)->setMethods(['getId'])->getMock(); $this->formElementManager = $this->getMockBuilder(ServiceLocatorInterface::class)->getMock(); $this->formElementManager->expects($this->any())->method('get')->with($this->formService)->willReturn(new CoreForm()); $this->collectionContainer = new CollectionContainer($this->formService, $this->newEntry); $this->collectionContainer->setFormElementManager($this->formElementManager); }
/** * Prepare the object to be tested. */ protected function setUp() { $this->serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $this->options = $this->getMockBuilder('ZfcUser\\Options\\ModuleOptions')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->any())->method('get')->with('zfcuser_module_options')->will($this->returnValue($this->options)); $this->eventManager = new \Zend\EventManager\EventManager(); $this->factory = new AdapterChainServiceFactory(); }
/** * {@inheritDoc} * * @covers \BjyAuthorize\Guard\Controller::__construct */ public function setUp() { parent::setUp(); $this->serviceLocator = $locator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $this->authorize = $authorize = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false); $this->controllerGuard = new Controller(array(), $this->serviceLocator); $this->serviceLocator->expects($this->any())->method('get')->with('BjyAuthorize\\Service\\Authorize')->will($this->returnValue($authorize)); }
/** * Test methods */ public function testMethods() { $helper = $this->appService; $this->assertSame($this->serviceLocatorMock, $helper->getServiceLocator()); $this->assertSame($this->serviceLocatorMock, $helper()); $this->serviceLocatorMock->expects($this->once())->method('get')->with('ExampleService')->will($this->returnValue(new \stdClass())); $this->assertInstanceOf('stdClass', $helper('ExampleService')); }
/** * @covers Eye4web\ZfcUser\Pm\Factory\View\Helper\ZfcUserPmHelperFactory::createService */ public function testCreateService() { $pmService = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Service\\PmService')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Service\\PmService')->willReturn($pmService); $user = $this->getMockForAbstractClass('ZfcUser\\Mapper\\UserInterface'); $this->serviceLocator->expects($this->at(1))->method('get')->with('zfcuser_user_mapper')->will($this->returnValue($user)); $result = $this->factory->createService($this->helperManager); $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\View\\Helper\\ZfcUserPmHelper', $result); }
public function testCreateService() { $formElementManager = $this->getMockBuilder('Zend\\Form\\FormElementManager')->disableOriginalConstructor()->getMock(); $captchaForm = $this->getMockBuilder('LearnZF2Captcha\\Form\\CaptchaForm')->disableOriginalConstructor()->getMock(); $formElementManager->expects($this->once())->method('get')->with('LearnZF2Captcha\\Form\\CaptchaForm')->willReturn($captchaForm); $this->serviceLocator->expects($this->once())->method('get')->with('FormElementManager')->willReturn($formElementManager); $result = $this->factory->createService($this->controllerManager); $this->assertInstanceOf('LearnZF2Captcha\\Controller\\CaptchaController', $result); }
public function testCreateService() { $userSettingService = $this->getMockBuilder('Eye4web\\ZfcUser\\Settings\\Service\\UserSettingsService')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Settings\\Service\\UserSettingsService')->willReturn($userSettingService); $zfcUserIdentityViewHelper = $this->getMockBuilder('ZfcUser\\View\\Helper\\ZfcUserIdentity')->disableOriginalConstructor()->getMock(); $this->viewHelperManager->expects($this->once())->method('get')->with('ZfcUserIdentity')->willReturn($zfcUserIdentityViewHelper); $result = $this->factory->createService($this->viewHelperManager); $this->assertInstanceOf('Eye4web\\ZfcUser\\Settings\\View\\Helper\\UserSettingHelper', $result); }
public function testCreateService() { $mockFormElementManager = $this->getMock('Zend\\Form\\FormElementManager'); $this->serviceLocator->expects($this->at(0))->method('get')->with('FormElementManager')->willReturn($mockFormElementManager); $mockLogForm = $this->getMock('LearnZF2Log\\Form\\LogForm'); $mockFormElementManager->expects($this->at(0))->method('get')->with('LearnZF2Log\\Form\\LogForm')->willReturn($mockLogForm); $result = $this->factory->createService($this->controllerManager); $this->assertInstanceOf('LearnZF2Log\\Controller\\IndexController', $result); }
public function testCreateService() { $userSettingService = $this->getMockBuilder('Eye4web\\ZfcUser\\Settings\\Service\\UserSettingsService')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Settings\\Service\\UserSettingsService')->willReturn($userSettingService); $zfcuser_auth_service = $this->getMockBuilder('Zend\\Authentication\\AuthenticationService')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(1))->method('get')->with('zfcuser_auth_service')->willReturn($zfcuser_auth_service); $result = $this->factory->createService($this->controllerPluginManager); $this->assertInstanceOf('Eye4web\\ZfcUser\\Settings\\Controller\\Plugin\\UserSettingPlugin', $result); }
/** * @covers Eye4web\ZfcUser\Pm\Factory\Service\PmServiceFactory::createService */ public function testCreateService() { $options = $this->getMock('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions'); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions')->willReturn($options); $options->expects($this->once())->method('getPmMapper')->will($this->returnValue('Eye4web\\ZfcUser\\Pm\\Mapper\\DoctrineORM\\PmMapper')); $pmMapperMock = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Mapper\\DoctrineORM\\PmMapper')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(1))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Mapper\\DoctrineORM\\PmMapper')->willReturn($pmMapperMock); $result = $this->factory->createService($this->serviceLocator); $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Service\\PmService', $result); }
/** * @covers Eye4web\ZfcUser\Pm\Factory\Mapper\DoctrineORM\PmMapperFactory::createService */ public function testCreateService() { $moduleOptions = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions')->willReturn($moduleOptions); $objectManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(1))->method('get')->with('Doctrine\\ORM\\EntityManager')->willReturn($objectManager); $options = $this->getMock('ZfcUser\\Options\\ModuleOptions'); $this->serviceLocator->expects($this->at(2))->method('get')->with('zfcuser_module_options')->will($this->returnValue($options)); $result = $this->factory->createService($this->serviceLocator); $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Mapper\\DoctrineORM\\PmMapper', $result); }
/** * {@inheritDoc} * * @covers \BjyAuthorize\Guard\Controller::__construct */ public function setUp() { parent::setUp(); $this->serviceLocator = $locator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $this->authorize = $authorize = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false); $this->controllerGuard = new Controller(array(), $this->serviceLocator); $this->serviceLocator->expects($this->any())->method('get')->will($this->returnCallback(function ($name) use($authorize) { if ($name === 'BjyAuthorize\\Service\\Authorize') { return $authorize; } throw new \UnexpectedValueException(); })); }
/** * @dataProvider provideCaptchaAdapterKeys */ public function testCreateService($captchaAdapterKey) { $config = (include __DIR__ . '/../../../../../config/captcha.config.php'); $this->serviceLocator->expects($this->at(0))->method('get')->with('Config')->willReturn($config); $application = $this->getMockBuilder('Zend\\Mvc\\Application')->disableOriginalConstructor()->getMock(); $mvcEvent = $this->getMockBuilder('Zend\\Mvc\\MvcEvent')->disableOriginalConstructor()->getMock(); $application->expects($this->once())->method('getMvcEvent')->willReturn($mvcEvent); $request = $this->getMockBuilder('Zend\\Http\\PhpEnvironment\\Request')->disableOriginalConstructor()->getMock(); $request->expects($this->once())->method('getQuery')->with('captcha_adapter')->willReturn($captchaAdapterKey); $mvcEvent->expects($this->once())->method('getRequest')->willReturn($request); $this->serviceLocator->expects($this->at(1))->method('get')->with('Application')->willReturn($application); $result = $this->factory->createService($this->formElementManager); $this->assertInstanceOf('LearnZF2Captcha\\Form\\CaptchaForm', $result); }
/** * getMockServiceLocator * * @return \Zend\ServiceManager\ServiceLocatorInterface */ public function getMockServiceLocator() { if (isset($this->mockServiceLocator)) { return $this->mockServiceLocator; } $this->mockServiceLocator = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceLocatorInterface')->disableOriginalConstructor()->getMock(); $this->mockServiceLocator->expects($this->any())->method('get')->will($this->returnValueMap($this->getValueMap())); return $this->mockServiceLocator; }
/** * @covers \OcraServiceManager\Controller\YumlController::indexAction */ public function testIndexActionWillFailOnMalformedResponse() { $this->serviceLocator->expects($this->any())->method('get')->with('Config')->will($this->returnValue(array('ocra_service_manager' => array('logged_service_manager' => true), 'zenddevelopertools' => array('toolbar' => array('enabled' => true))))); $client = $this->getMock('Zend\\Http\\Client'); $response = $this->getMock('Zend\\Http\\Response'); $client->expects($this->any())->method('send')->will($this->returnValue($response)); $response->expects($this->any())->method('isSuccess')->will($this->returnValue(false)); $this->controller->setHttpClient($client); $this->setExpectedException('UnexpectedValueException'); $this->controller->indexAction(); }
public function setUp() { $this->listener = new Listener(); $this->user = $this->getMockBuilder(User::class)->setMethods(['isActive'])->getMock(); $this->auth = $this->getMockBuilder(AuthenticationService::class)->setMethods(['authenticate', 'hasIdentity', 'getIdentity', 'clearIdentity', 'getUser'])->getMock(); $this->auth->expects($this->any())->method('getUser')->willReturn($this->user); $this->serviceManager = $this->getMockBuilder(ServiceManager::class)->setMethods(['get', 'has'])->getMock(); $this->serviceManager->expects($this->any())->method('get')->will($this->returnCallback(function ($name) { switch ($name) { case 'AuthenticationService': return $this->auth; break; default: throw new \InvalidArgumentException(); break; } })); $this->application = $this->getMockBuilder(Application::class)->setMethods(['getServiceManager', 'getRequest', 'getResponse', 'run', 'getEventManager'])->getMock(); $this->application->expects($this->any())->method('getServiceManager')->willReturn($this->serviceManager); $this->routeMatch = new RouteMatch([]); $this->event = $this->getMockBuilder(MvcEvent::class)->getMock(); $this->event->expects($this->any())->method('getApplication')->willReturn($this->application); $this->event->expects($this->any())->method('getRouteMatch')->willReturn($this->routeMatch); }
/** * @covers Eye4web\ZfcUser\Pm\Factory\Controller\PmControllerFactory::createService */ public function testCreateService() { $pmService = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Service\\PmService')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(0))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Service\\PmService')->willReturn($pmService); $newConversationFormService = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Form\\NewConversationForm')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(1))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Form\\NewConversationForm')->willReturn($newConversationFormService); $newMessageForm = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Form\\NewMessageForm')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(2))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Form\\NewMessageForm')->willReturn($newMessageForm); $deleteConversationForm = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Form\\DeleteConversationsForm')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(3))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Form\\DeleteConversationsForm')->willReturn($deleteConversationForm); $moduleOptions = $this->getMockBuilder('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(4))->method('get')->with('Eye4web\\ZfcUser\\Pm\\Options\\ModuleOptions')->willReturn($moduleOptions); $zfcModuleOptions = $this->getMockBuilder('ZfcUser\\Options\\ModuleOptions')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(5))->method('get')->with('zfcuser_module_options')->willReturn($zfcModuleOptions); $eventManager = $this->getMockBuilder('Zend\\EventManager\\EventManagerInterface')->disableOriginalConstructor()->getMock(); $this->serviceLocator->expects($this->at(6))->method('get')->with('EventManager')->willReturn($eventManager); $result = $this->factory->createService($this->controllerManager); $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Controller\\PmController', $result); }
public function testGetMainItems() { $this->serviceLocatorMock->expects($this->once())->method('get')->with('config')->will($this->returnValue(['nav' => [['key1' => 'value1'], ['key2' => 'value2'], ['main' => 'abc', 'key3' => 'value3'], ['main' => ''], ['main' => false]]])); $this->assertEquals([['main' => 'abc', 'key3' => 'value3']], array_values($this->navigation->getMainItems())); }