/** * Find a matching user given a token * * @param Token $token * * @return null|User * * @throws NotAuthenticatedException In case the token is not authenticated. */ public function find(Token $token) { $infos = $token->getIdentity(); if ($infos->has(Identity::PROPERTY_EMAIL)) { return $this->repository->findByEmail($infos->get(Identity::PROPERTY_EMAIL)); } return null; }
public function getTemplates() { $provider = $this->getMock('Alchemy\\Phrasea\\Authentication\\Provider\\ProviderInterface'); $id = 'Id-' . mt_rand(); $identity = $this->getMockBuilder('Alchemy\\Phrasea\\Authentication\\Provider\\Token\\Identity')->disableOriginalConstructor()->getMock(); $provider->expects($this->once())->method('getIdentity')->will($this->returnValue($identity)); $templates = [25, 42]; $provider->expects($this->once())->method('getTemplates')->with($identity)->will($this->returnValue($templates)); $token = new Token($provider, $id); $this->assertEquals($templates, $token->getTemplates()); }