$id = $storage->getSessionId(); $user->setAuthenticated(true); $t->isnt($id, $id = $storage->getSessionId(), '->setAuthenticated() regenerates the session id if the authentication changes'); $user->setAuthenticated(true); $t->is($storage->getSessionId(), $id, '->setAuthenticated() does not regenerate the session id if the authentication does not change'); $user->addCredential('foo'); $t->isnt($id, $id = $storage->getSessionId(), '->addCredential() regenerates the session id if a new credential is added'); $t->is($id, $storage->getSessionId(), '->addCredential() does not regenerate the session id if the credential already exists'); $user->removeCredential('foo'); $t->isnt($id, $id = $storage->getSessionId(), '->removeCredential() regenerates the session id if a credential is removed'); $t->is($id, $storage->getSessionId(), '->removeCredential() does not regenerate the session id if the credential does not exist'); // ->setTimedOut() ->getTimedOut() $user = new sfBasicSecurityUser($dispatcher, $storage); $t->diag('->setTimedOut() ->isTimedOut()'); $t->is($user->isTimedOut(), false, '->isTimedOut() returns false if the session is not timed out'); $user->setTimedOut(); $t->is($user->isTimedOut(), true, '->isTimedOut() returns true if the session is timed out'); // ->hasCredential() $t->diag('->hasCredential()'); $user->clearCredentials(); $t->is($user->hasCredential('admin'), false, '->hasCredential() returns false if user has not the credential'); $user->addCredential('admin'); $t->is($user->hasCredential('admin'), true, '->addCredential() takes a credential as its first argument'); // admin AND user $t->is($user->hasCredential(array('admin', 'user')), false, '->hasCredential() can takes an array of credential as a parameter'); // admin OR user $t->is($user->hasCredential(array(array('admin', 'user'))), true, '->hasCredential() can takes an array of credential as a parameter'); // (admin OR user) AND owner $t->is($user->hasCredential(array(array('admin', 'user'), 'owner')), false, '->hasCredential() can takes an array of credential as a parameter'); $user->addCredential('owner'); $t->is($user->hasCredential(array(array('admin', 'user'), 'owner')), true, '->hasCredential() can takes an array of credential as a parameter');