/** * Creates an instance of \Auth\View\Helper\Auth * * - Injects the AuthenticationService * * @param ServiceLocatorInterface $helpers * @return \Auth\View\Helper\Auth * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $helpers) { $auth = $helpers->getServiceLocator()->get('AuthenticationService'); $helper = new Auth(); $helper->setService($auth); return $helper; }
public function testHelperReturnsNullWhenInvalidPropertyIsRequested() { $auth = $this->getPropertyTestAuthMock(); $helper = new Auth(); $helper->setService($auth); $this->assertNull($helper('___invalid_property___')); }
/** * Creates an instance of \Auth\View\Helper\Auth * * - Injects the AuthenticationService * * @param ServiceLocatorInterface $helpers * @return \Auth\View\Helper\Auth * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $helpers) { /* @var $helpers \Zend\View\HelperPluginManager */ $auth = $helpers->getServiceLocator()->get('AuthenticationService'); $helper = new Auth(); $helper->setService($auth); return $helper; }
public function testIsAbleToCheckIfAUserIsCurrentlyLoggedIn() { $auth = $this->getMockBuilder('Auth\\AuthenticationService')->disableOriginalConstructor()->getMock(); $auth->expects($this->exactly(2))->method('hasIdentity')->will($this->onConsecutiveCalls(true, false)); $target = new AuthHelper(); $target->setService($auth); $this->assertTrue($target->isLoggedIn()); $this->assertFalse($target->isLoggedIn()); }