/** * Test that authenticating a token with valid credentials for which no user can be loaded fails. * * @return void * * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException * * @expectedExceptionMessage Invalid token - could not derive user from credentials. */ public function testAuthenticateTokenFailsWhenUserCanNotBeLoaded() { $config = new TensideJsonConfig(new JsonFile($this->getTempDir() . DIRECTORY_SEPARATOR . 'tenside.json')); $config->set('secret', 'very-secret-secret'); $auth = new JWTAuthenticator($config); $token = $this->getMockBuilder(TokenInterface::class)->setMethods(['getCredentials'])->getMockForAbstractClass(); $token->method('getCredentials')->willReturn((object) ['username' => 'user']); $userProvider = $this->getMockForAbstractClass(UserProviderInterface::class); $auth->authenticateToken($token, $userProvider, 'provider-key'); }