/** * @dataProvider provideCaptchaAdapterKeys */ public function testCreateService($captchaAdapterKey) { $config = (include __DIR__ . '/../../../../../config/captcha.config.php'); $this->serviceLocator->get('Config')->willReturn($config); $application = $this->prophesize('Zend\\Mvc\\Application'); $mvcEvent = $this->prophesize('Zend\\Mvc\\MvcEvent'); $application->getMvcEvent()->willReturn($mvcEvent); $request = $this->prophesize('Zend\\Http\\PhpEnvironment\\Request'); $request->getQuery('captcha_adapter', 0)->willReturn($captchaAdapterKey); $mvcEvent->getRequest()->willReturn($request); $this->serviceLocator->get('Application')->willReturn($application); $result = $this->factory->createService($this->formElementManager->reveal()); $this->assertInstanceOf('LearnZF2Captcha\\Form\\CaptchaForm', $result); }
/** * @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); }