public function testFileCookieJar($testSaveSessionCookie = false) { $guzzle = $this->getGuzzle(); $client = new Client(); $client->setClient($guzzle); $filename = tempnam('/tmp', 'file-cookies'); $jar = new FileCookieJar($filename, $testSaveSessionCookie); $client->setGuzzleCookieJar($jar); $client->getCookieJar()->set(new Cookie('test', '123')); $client->getCookieJar()->set(new Cookie('foo', 'bar', time() + 1000)); $client->request('GET', 'http://www.example.com/'); // Call to destruct method manually to test saving cookies $jar->__destruct(); // Make sure it wrote to the file $contents = file_get_contents($filename); $this->assertNotEmpty($contents); // Load the cookieJar from the file $cookieJarReloaded = new FileCookieJar($filename); if ($testSaveSessionCookie) { $this->assertEquals(2, count($cookieJarReloaded)); } else { $this->assertEquals(1, count($cookieJarReloaded)); } unlink($filename); }