/** * Log in as sfDoctrineGuardUser. * Only name of user should be provided. * Fetches user by it's username from sfGuardUser table. * * @param $name * @throws \Exception */ public function amLoggedAs($name) { if (!class_exists('Doctrine')) { throw new \Exception('Doctrine is not installed. Consider using \'signIn\' action instead'); } $user = \Doctrine::getTable('sfGuardUser')->findOneBy('username', $name); if (!$user) { throw new \Exception("User with name {$name} was not found in database"); } $user->clearRelated(); $browser = $this->browser; $this->browser->getContext()->getStorage()->initialize($browser->getContext()->getStorage()->getOptions()); $browser->getUser()->signIn($user); $this->debug('session: ' . json_encode($this->browser->getUser()->getAttributeHolder()->getAll())); $this->debug('user: '******'sfGuardSecurityUser'))); $this->debug('credentials: ' . json_encode($this->browser->getUser()->getCredentials())); $this->browser->getUser()->shutdown(); $this->browser->getContext()->getStorage()->shutdown(); $browser->get('/'); $this->followRedirect(); }