/**
  * @covers Guzzle\Http\CookieJar\FileCookieJar
  */
 public function testPersistsToFileFile()
 {
     unset($this->jar);
     $this->jar = new FileCookieJar($this->file);
     $this->addCookies();
     $this->assertEquals(4, count($this->jar->getCookies()));
     unset($this->jar);
     // Make sure it wrote to the file
     $contents = file_get_contents($this->file);
     $this->assertNotEmpty($contents);
     // Load the jar from the file
     $jar = new FileCookieJar($this->file);
     // Weeds out temporary and session cookies
     $this->assertEquals(3, count($jar->getCookies()));
     unset($jar);
     unlink($this->file);
 }
Ejemplo n.º 2
0
 /**
  * @covers Guzzle\Http\CookieJar\FileCookieJar
  */
 public function testPersistsToFileFile()
 {
     $jar = new FileCookieJar($this->file);
     $jar->add(new Cookie(array('name' => 'foo', 'value' => 'bar', 'domain' => 'foo.com', 'expires' => time() + 1000)));
     $jar->add(new Cookie(array('name' => 'baz', 'value' => 'bar', 'domain' => 'foo.com', 'expires' => time() + 1000)));
     $jar->add(new Cookie(array('name' => 'boo', 'value' => 'bar', 'domain' => 'foo.com')));
     $this->assertEquals(3, count($jar));
     unset($jar);
     // Make sure it wrote to the file
     $contents = file_get_contents($this->file);
     $this->assertNotEmpty($contents);
     // Load the cookieJar from the file
     $jar = new FileCookieJar($this->file);
     // Weeds out temporary and session cookies
     $this->assertEquals(2, count($jar));
     unset($jar);
     unlink($this->file);
 }