當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::getCookieJar方法代碼示例

本文整理匯總了PHP中Symfony\Bundle\FrameworkBundle\Client::getCookieJar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getCookieJar方法的具體用法?PHP Client::getCookieJar怎麽用?PHP Client::getCookieJar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Bundle\FrameworkBundle\Client的用法示例。


在下文中一共展示了Client::getCookieJar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: logout

 public function logout()
 {
     $this->client->setServerParameters(array());
     $this->client->getCookieJar()->clear();
     $this->user = null;
     $this->pageEleveur = null;
 }
開發者ID:apflieger,項目名稱:zigotoo,代碼行數:7,代碼來源:TestUtils.php

示例2: signInAsAdmin

 /**
  *
  */
 protected function signInAsAdmin()
 {
     $session = $this->client->getContainer()->get('session');
     $firewall = 'main';
     $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:Nemrtvej,項目名稱:symfony-template,代碼行數:13,代碼來源:ApplicationAvailabilityFunctionalTest.php

示例3: logIn

 /**
  * @param User $user
  */
 protected function logIn(User $user)
 {
     $session = $this->client->getContainer()->get('session');
     $firewall = 'main';
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:philipsorst,項目名稱:ddr-symfony-stack.php,代碼行數:13,代碼來源:BaseIntegrationTest.php

示例4: logIn

 protected function logIn()
 {
     $session = $this->client->getContainer()->get('session');
     $userManager = $this->client->getContainer()->get('fos_user.user_manager');
     $user = $userManager->findUserByUsername('admin');
     $firewall = 'main';
     $token = new UsernamePasswordToken($user, null, $firewall, array('ROLE_ADMIN'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:vsmihaylovsky,項目名稱:GeekHubSymfonyShop,代碼行數:12,代碼來源:TestBaseWeb.php

示例5: iAmAuthenticatedAs

 /**
  * @Given I am authenticated as :login
  */
 public function iAmAuthenticatedAs($login)
 {
     /** @var User $user */
     $user = $this->getContainer()->get('fos_user.user_manager')->findUserByUsername($login);
     $session = $this->client->getContainer()->get('session');
     $this->client->getCookieJar()->set(new Cookie($session->getName(), true));
     $firewall = 'main';
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $this->getContainer()->get('security.context')->setToken($token);
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:Im0rtality,項目名稱:rest-api-bundle,代碼行數:17,代碼來源:FeatureContext.php

示例6: authenticateUser

 /**
  * Authenticate selected user.
  * If you want to test another firewall, look name for it
  * in the security.yml file for "context" value.
  *
  * @param $userName
  * @param $roles
  * @param null $firewallName
  * @return \FOS\UserBundle\Model\UserInterface
  */
 protected function authenticateUser($userName, $roles, $firewallName = null)
 {
     $session = $this->client->getContainer()->get('session');
     if (!$firewallName) {
         $firewallName = $this->getFirewallName();
     }
     $user = $this->container->get('fos_user.user_manager')->findUserByUsername($userName);
     $token = new UsernamePasswordToken($user, null, $firewallName, $roles);
     $session->set('_security_' . $firewallName, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
     return $user;
 }
開發者ID:junjinZ,項目名稱:wealthbot,代碼行數:24,代碼來源:ExtendedWebTestCase.php

示例7: logIn

 /**
  * Log user with username
  */
 protected function logIn()
 {
     $container = $this->client->getContainer();
     $userManager = $container->get('fos_user.user_manager');
     $user = $userManager->findUserByUsername($this->username);
     $session = $this->client->getContainer()->get('session');
     $firewall = 'openorchestra';
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $container->get('fos_user.security.login_manager')->logInUser($firewall, $user);
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:open-orchestra,項目名稱:open-orchestra,代碼行數:17,代碼來源:AbstractAuthenticatedTest.php

示例8: setSettingsCookie

 /**
  * Create settings cookies and set it in the cookie jar.
  *
  * @param Client $client
  * @param array  $cookies
  */
 public static function setSettingsCookie(Client $client, array $cookies)
 {
     foreach ($cookies as $name => $cookieSettings) {
         $cookie = new Cookie($name, json_encode($cookieSettings));
         $client->getCookieJar()->set($cookie);
     }
 }
開發者ID:asev,項目名稱:SettingsBundle,代碼行數:13,代碼來源:CookieTestHelper.php

示例9: expireAuthentication

 /**
  * Expires the authentication if these has been created
  *
  * @param Url $url Url
  *
  * @return $this Self object
  */
 protected function expireAuthentication(Url $url)
 {
     $session = $this->session;
     $session->remove('_security_' . $url->getOption('firewall'));
     $session->save();
     $this->client->getCookieJar()->expire($session->getName());
     return $this;
 }
開發者ID:jverdeyen-forks,項目名稱:VisithorBundle,代碼行數:15,代碼來源:SymfonyClient.php

示例10: logIn

 /**
  * Do not use this method in dataProvider since they are called before setUp !
  */
 protected function logIn($nick)
 {
     $repo = $this->getService('social.netizen.repository');
     $user = $repo->findByNickname($nick);
     if (!is_null($user)) {
         $session = $this->client->getContainer()->get('session');
         $firewall = 'secured_area';
         $cred = $user->getCredential();
         $token = new Token($firewall, $cred->getProviderKey(), $cred->getUid(), $user->getRoles());
         $token->setUser($user);
         $session->set('_security_' . $firewall, serialize($token));
         $session->save();
         $cookie = new Cookie($session->getName(), $session->getId());
         $this->client->getCookieJar()->set($cookie);
         $this->getService('security.context')->setToken($token);
     }
 }
開發者ID:xtrasmal,項目名稱:iinano,代碼行數:20,代碼來源:WebTestCasePlus.php

示例11: logIn

 /**
  *
  * @param string $username
  * @param array $role
  */
 protected function logIn($username = null, $role = null)
 {
     $session = $this->client->getContainer()->get('session');
     $firewall = 'main';
     $user = $this->em->getRepository('OjsUserBundle:User')->findOneByUsername($username ? $username : 'admin');
     if (!$user) {
         $_role = $this->em->getRepository('OjsUserBundle:Role')->findOneByRole($role[0]);
         $user = $this->em->getRepository('OjsUserBundle:User')->findOneByRole($_role);
     }
     if (!$user instanceof UserInterface) {
         throw new \Exception("User not find. " . get_class($user));
     }
     $token = new UsernamePasswordToken($user, null, $firewall, $role ? $role : array('ROLE_SUPER_ADMIN'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
開發者ID:hasantayyar,項目名稱:ojs,代碼行數:23,代碼來源:BaseTestCase.php

示例12: adminLogIn

 protected function adminLogIn(Client $client)
 {
     $session = $client->getContainer()->get('session');
     $firewall = 'secured_area';
     $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
開發者ID:leaphly,項目名稱:leaphly-sandbox,代碼行數:10,代碼來源:WebTestCase.php

示例13: setCookieAndAssertFail

 /**
  * @param mixed  $cookieValue
  * @param Cookie $oldCookie
  */
 private function setCookieAndAssertFail($cookieValue, $oldCookie)
 {
     // Set cookie.
     $newCookie = new \Symfony\Component\BrowserKit\Cookie('ongr_settings_user_auth', json_encode($cookieValue), $oldCookie->getExpiresTime(), $oldCookie->getPath(), $oldCookie->getDomain());
     $this->client->getCookieJar()->set($newCookie);
     // Visit login page.
     $crawler = $this->client->request('GET', '/settings/login');
     // Assert there is a form.
     $buttonNode = $crawler->selectButton('login_submit');
     $this->assertSame(1, $buttonNode->count(), 'There should be a form');
 }
開發者ID:asev,項目名稱:SettingsBundle,代碼行數:15,代碼來源:UserControllerTest.php

示例14: loginIn

 /**
  * @param Client $client
  * @param string $token
  */
 public function loginIn(Client $client, $token)
 {
     $session = $client->getContainer()->get('session');
     $user = new User(new UserId('$token'), $token);
     $token = new BlockCypherUserToken($user, $token, 'blockcypher', array('ROLE_USER'));
     $firewall = 'secured_area';
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
開發者ID:qiyu2580,項目名稱:php-wallet-sample,代碼行數:15,代碼來源:WebTestCase.php

示例15: login

 /**
  * @param Client $client
  * @param string $username
  * @param string $password
  */
 protected function login($client, $username = null, $password = null)
 {
     $session = $client->getContainer()->get('session');
     // the firewall context (defaults to the firewall name)
     $firewall = 'secured_area';
     $token = new UsernamePasswordToken('root', "root", $firewall, array('ROLE_ADMIN'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
開發者ID:mapbender,項目名稱:search,代碼行數:16,代碼來源:ManagerTest.php


注:本文中的Symfony\Bundle\FrameworkBundle\Client::getCookieJar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。