예제 #1
0
 function testCookieJarIsSentToRequest()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'A');
     $request =& new MockSimpleHttpRequest();
     $request->setReturnReference('fetch', $this->_createStandardResponse());
     $request->expectOnce('readCookiesFromJar', array($jar, '*'));
     $agent =& $this->_createMockedRequestUserAgent($request);
     $agent->setCookie('a', 'A');
     $agent->fetchResponse(new SimpleUrl('http://this.com/this/path/page.html'), new SimpleGetEncoding());
 }
예제 #2
0
 /**
  *    Writes new cookies to the cookie jar.
  *    @param SimpleCookieJar $jar   Jar to write to.
  *    @param SimpleUrl $url         Host and path to write under.
  *    @access public
  */
 function writeCookiesToJar(&$jar, $url)
 {
     foreach ($this->_cookies as $cookie) {
         $jar->setCookie($cookie->getName(), $cookie->getValue(), $url->getHost(), $cookie->getPath(), $cookie->getExpiry());
     }
 }
예제 #3
0
 function testCookieClearByLoweringDate()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'abc', false, '/', 'Wed, 25-Dec-02 04:24:21 GMT');
     $jar->setCookie('a', 'def', false, '/', 'Wed, 25-Dec-02 04:24:19 GMT');
     $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=def'));
     $jar->restartSession('Wed, 25-Dec-02 04:24:20 GMT');
     $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
 }
예제 #4
0
 function testMultipleCookieWriting()
 {
     $socket =& new MockSimpleSocket();
     $socket->expectArgumentsAt(0, 'write', array("Cookie: a=A;b=B\r\n"));
     $route =& new MockSimpleRoute();
     $route->setReturnReference('createConnection', $socket);
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'A');
     $jar->setCookie('b', 'B');
     $request =& new SimpleHttpRequest($route, new SimpleGetEncoding());
     $request->readCookiesFromJar($jar, new SimpleUrl('/'));
     $request->fetch(15);
 }
예제 #5
0
 function testCookieClearByDate()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie(new SimpleCookie("a", "abc", "/", "Wed, 25-Dec-02 04:24:21 GMT"));
     $jar->setCookie(new SimpleCookie("a", "def", "/", "Wed, 25-Dec-02 04:24:19 GMT"));
     $cookies = $jar->getValidCookies(false, "/");
     $this->assertIdentical($cookies[0]->getValue(), "def");
     $jar->restartSession("Wed, 25-Dec-02 04:24:20 GMT");
     $this->assertEqual(count($jar->getValidCookies(false, "/")), 0);
 }