Beispiel #1
0
 public function testAdd()
 {
     $pool = new CookiePool();
     $cookie1 = new MutableCookie('foo', 'bar');
     $pool->add($cookie1);
     $this->assertSame($cookie1, $pool['foo']);
     $cookie2 = $this->getMockBuilder('Jivoo\\Http\\Cookie\\ResponseCookie')->getMock();
     $cookie2->method('getName')->willReturn('baz');
     $cookie2->method('get')->willReturn('foobar');
     $cookie2->method('getPath')->willReturn('/baz/bar');
     $pool->add($cookie2);
     $this->assertTrue(isset($pool['baz']));
     $this->assertEquals('foobar', $pool['baz']->get());
     $this->assertEquals('/baz/bar', $pool['baz']->getPath());
     $cookie3 = $this->getMockBuilder('Jivoo\\Http\\Cookie\\Cookie')->getMock();
     $cookie3->method('getName')->willReturn('bar');
     $cookie3->method('get')->willReturn('baz');
     $pool->add($cookie3);
     $this->assertTrue(isset($pool['bar']));
     $this->assertEquals('baz', $pool['bar']->get());
     $array = iterator_to_array($pool);
     $this->assertCount(3, $array);
 }
Beispiel #2
-2
 /**
  * @return Cookie\CookiePool
  */
 public function getCookies()
 {
     if (!isset($this->cookies)) {
         $server = $this->request->getServerParams();
         $secure = isset($server['HTTPS']) && $server['HTTPS'] != 'off';
         $this->cookies = new Cookie\CookiePool($this->path, $this->domain, true, $secure);
         foreach ($this->request->getCookieParams() as $name => $value) {
             $this->cookies->add(new Cookie\RequestCookie($name, $value));
         }
     }
     return $this->cookies;
 }