credentials)) { $this->allowedCredentials = $config->credentials; } if ($config->name) { $this->name = $config->name; } else { $this->name = 'TestBackendMock-' . uniqid(); } } public function hasUsername(Credential $userCredentials) { foreach ($this->allowedCredentials as $credential) { if ($credential->getUsername() == $userCredentials->getUsername()) { return true; } } return false; } /** * Name of the backend * * @return string */ public function getName() { return $this->name; } public static function getDummyUser() { return new User( 'Username', 'Firstname', 'Lastname', 'user@test.local' ); } public function getUserCount() { return count($this->allowedCredentials); } public function authenticate(Credential $credentials) { if (!in_array($credentials, $this->allowedCredentials)) { return false; } return self::getDummyUser(); } public function setCredentials(array $credentials) { $this->allowedCredentials = $credentials; } }