Example #1
0
 /**
  * @param string $key
  */
 public function setKey($key = null)
 {
     $this->key = $key ?: uniqid('phantomjs');
     $this->cookie->open($this->key);
     $this->setDefaultOption(self::COOKIES_FILE, $this->cookie->getFileFormName());
 }
 public function testToFile()
 {
     $cookie = new PhantomJsCookie();
     $cookie->open(uniqid(self::$name));
     $cookie->add('PHPSESSID', 'asdf123465', '.test1.ru', '/', date('D, d-M-y H:i:s', time() + 100000) . ' GMT', false, false, true);
     $cookie->add('testName', 'testValue', '.test1.ru', '/', date('D, d-M-y H:i:s', time() + 100000) . ' GMT', false, false, true);
     $cookie->toFile($cookie->get('test1.ru'));
     $testCookie = $cookie->fromFile($cookie->getFileFormName());
     $this->assertArrayHasKey('testName', $testCookie);
     $this->assertArrayHasKey('value', $testCookie['testName']);
     $this->assertEquals('testValue', $testCookie['testName']['value']);
     $this->assertArrayHasKey('PHPSESSID', $testCookie);
     $this->assertArrayHasKey('value', $testCookie['PHPSESSID']);
     $this->assertEquals('asdf123465', $testCookie['PHPSESSID']['value']);
 }