当前位置: 首页>>代码示例>>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;未经允许,请勿转载。