public function testName() { $name = 'testName'; $this->assertNull($this->organization->getName()); $this->organization->setName($name); $this->assertEquals($name, $this->organization->getName()); $this->assertEquals($name, (string) $this->organization); }
/** * Check * @param User $user * @param Organization $organization * @param string $class * @param string $username * @param int $organizationId * @param int $expires * @param string $hash */ protected function checkUserData(User $user, Organization $organization, $class, $username, $organizationId, $expires, $hash) { if (!$user instanceof UserInterface) { throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', get_class($user))); } if (!$organization instanceof Organization) { throw new \RuntimeException(sprintf('Can not find organization with id "%s".', $organizationId)); } if (!$organization->isEnabled()) { throw new \RuntimeException(sprintf('Organization "%s" is not active.', $organization->getName())); } if (!$user->getOrganizations()->contains($organization)) { throw new AuthenticationException(sprintf('User "%s" does not have access to organization "%s".', $username, $organization->getName())); } $isHashesIdentical = $this->compareHashes($hash, $this->generateCookieHash($class, $username, $expires, $user->getPassword())); if (true !== $isHashesIdentical) { throw new AuthenticationException('The cookie\'s hash is invalid.'); } if ($expires < time()) { throw new AuthenticationException('The cookie has expired.'); } }