当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getCookieJar方法代码示例

本文整理汇总了PHP中Symfony\Component\BrowserKit\Client::getCookieJar方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getCookieJar方法的具体用法?PHP Client::getCookieJar怎么用?PHP Client::getCookieJar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\BrowserKit\Client的用法示例。


在下文中一共展示了Client::getCookieJar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _before

 public function _before(\Codeception\TestCase $test)
 {
     if (!$this->client) {
         if (!strpos($this->config['url'], '://')) {
             // not valid url
             foreach ($this->getModules() as $module) {
                 if ($module instanceof \Codeception\Lib\Framework) {
                     $this->client = $module->client;
                     $this->isFunctional = true;
                     break;
                 }
             }
         } else {
             if (!$this->hasModule('PhpBrowser')) {
                 throw new ModuleConfigException(__CLASS__, "For REST testing via HTTP please enable PhpBrowser module");
             }
             $this->client = $this->getModule('PhpBrowser')->client;
         }
         if (!$this->client) {
             throw new ModuleConfigException(__CLASS__, "Client for REST requests not initialized.\nProvide either PhpBrowser module, or a framework module which shares FrameworkInterface");
         }
     }
     $this->headers = array();
     $this->params = array();
     $this->response = "";
     $this->client->setServerParameters(array());
     if ($this->config['xdebug_remote'] && function_exists('xdebug_is_enabled') && xdebug_is_enabled() && ini_get('xdebug.remote_enable') && !$this->isFunctional) {
         $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
         $this->client->getCookieJar()->set($cookie);
     }
 }
开发者ID:huynt57,项目名称:bluebee-uet.com,代码行数:31,代码来源:REST.php

示例2: _before

 public function _before(\Codeception\TestCase $test)
 {
     $this->client =& $this->connectionModule->client;
     $this->resetVariables();
     if ($this->config['xdebug_remote'] && function_exists('xdebug_is_enabled') && ini_get('xdebug.remote_enable') && !$this->isFunctional) {
         $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
         $this->client->getCookieJar()->set($cookie);
     }
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:9,代码来源:REST.php

示例3: setCookiesFromOptions

 protected function setCookiesFromOptions()
 {
     if (isset($this->config['cookies']) && is_array($this->config['cookies']) && !empty($this->config['cookies'])) {
         $domain = parse_url($this->config['url'], PHP_URL_HOST);
         $cookieJar = $this->client->getCookieJar();
         foreach ($this->config['cookies'] as &$cookie) {
             if (!is_array($cookie) || !array_key_exists('Name', $cookie) || !array_key_exists('Value', $cookie)) {
                 throw new \InvalidArgumentException('Cookies must have at least Name and Value attributes');
             }
             if (!isset($cookie['Domain'])) {
                 $cookie['Domain'] = $domain;
             }
             if (!isset($cookie['Expires'])) {
                 $cookie['Expires'] = null;
             }
             if (!isset($cookie['Path'])) {
                 $cookie['Path'] = '/';
             }
             if (!isset($cookie['Secure'])) {
                 $cookie['Secure'] = false;
             }
             if (!isset($cookie['HttpOnly'])) {
                 $cookie['HttpOnly'] = false;
             }
             $cookieJar->set(new \Symfony\Component\BrowserKit\Cookie($cookie['Name'], $cookie['Value'], $cookie['Expires'], $cookie['Path'], $cookie['Domain'], $cookie['Secure'], $cookie['HttpOnly']));
         }
     }
 }
开发者ID:neronmoon,项目名称:Codeception,代码行数:28,代码来源:InnerBrowser.php

示例4: logIn

 public function logIn(Client $client)
 {
     $session = $client->getContainer()->get('session');
     $firewall = 'admin';
     $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_USER'));
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
开发者ID:saro0h,项目名称:sf2c2,代码行数:10,代码来源:AbstractTest.php

示例5: _before

 public function _before(\Codeception\TestCase $test)
 {
     if (!$this->client) {
         if (!strpos($this->config['url'], '://')) {
             // not valid url
             foreach ($this->getModules() as $module) {
                 if ($module instanceof \Codeception\Util\Framework) {
                     $this->client = $module->client;
                     $this->is_functional = true;
                     break;
                 }
             }
         } else {
             if (!$this->hasModule('PhpBrowser')) {
                 throw new ModuleConfigException(__CLASS__, "For REST testing via HTTP please enable PhpBrowser module");
             }
             $this->client = $this->getModule('PhpBrowser')->session->getDriver()->getClient();
         }
         if (!$this->client) {
             throw new ModuleConfigException(__CLASS__, "Client for REST requests not initialized.\nProvide either PhpBrowser module, or a framework module which shares FrameworkInterface");
         }
     }
     $this->headers = array();
     $this->params = array();
     $this->response = "";
     $this->client->setServerParameters(array());
     $timeout = $this->config['timeout'];
     if ($this->config['xdebug_remote'] && function_exists('xdebug_is_enabled') && xdebug_is_enabled() && ini_get('xdebug.remote_enable')) {
         $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
         $this->client->getCookieJar()->set($cookie);
         // timeout is disabled, so we can debug gently :)
         $timeout = 0;
     }
     if (method_exists($this->client, 'getClient')) {
         $clientConfig = $this->client->getClient()->getConfig();
         $curlOptions = $clientConfig->get('curl.options');
         $curlOptions[CURLOPT_TIMEOUT] = $timeout;
         $clientConfig->set('curl.options', $curlOptions);
     }
 }
开发者ID:pfz,项目名称:codeception,代码行数:40,代码来源:REST.php

示例6: authorizeClient

 /**
  * Create authorized client
  *
  * @link http://stackoverflow.com/questions/14957807/symfony2-tests-with-fosuserbundle/27223293#27223293
  * @return Client
  */
 public static function authorizeClient(Client $client)
 {
     $container = $client->getContainer();
     $session = $container->get('session');
     /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
     $userManager = $container->get('fos_user.user_manager');
     /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
     $loginManager = $container->get('fos_user.security.login_manager');
     $firewallName = $container->getParameter('fos_user.firewall_name');
     /// @todo create fixture for this
     $testUser = $container->getParameter('test_user');
     $user = $userManager->findUserBy(array('username' => $testUser));
     $loginManager->loginUser($firewallName, $user);
     // save the login token into the session and put it in a cookie
     $token = $container->get('security.context')->getToken();
     $session->set('_security_' . $firewallName, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
     return $client;
 }
开发者ID:hikmahtiar6,项目名称:drafterbit,代码行数:27,代码来源:WebTestCase.php

示例7: resetCookie

 public function resetCookie($name)
 {
     $this->client->getCookieJar()->expire($name);
     $this->debugSection('Cookies', $this->client->getCookieJar()->all());
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:5,代码来源:InnerBrowser.php

示例8: debugCookieJar

 protected function debugCookieJar()
 {
     $cookies = $this->client->getCookieJar()->all();
     $cookieStrings = array_map('strval', $cookies);
     $this->debugSection('Cookie Jar', $cookieStrings);
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:6,代码来源:InnerBrowser.php

示例9: resetCookie

 public function resetCookie($name, array $params = [])
 {
     $params = array_merge($this->defaultCookieParameters, $params);
     $this->client->getCookieJar()->expire($name, $params['path'], $params['domain']);
     $this->debugSection('Cookies', $this->client->getCookieJar()->all());
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:6,代码来源:InnerBrowser.php


注:本文中的Symfony\Component\BrowserKit\Client::getCookieJar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。