/** * Test that we can distinguish between vars that were loaded on instantiation * and those added later */ public function testExistingVersusNew() { //load with a cookie $cookieJar = new CookieJar(array('cookieExisting' => 'i woz here')); //set a new cookie $cookieJar->set('cookieNew', 'i am new'); //check we can fetch new and old cookie values $this->assertEquals('i woz here', $cookieJar->get('cookieExisting')); $this->assertEquals('i woz here', $cookieJar->get('cookieExisting', false)); $this->assertEquals('i am new', $cookieJar->get('cookieNew')); //there should be no original value for the new cookie $this->assertEmpty($cookieJar->get('cookieNew', false)); //change the existing cookie, can we fetch the new and old value $cookieJar->set('cookieExisting', 'i woz changed'); $this->assertEquals('i woz changed', $cookieJar->get('cookieExisting')); $this->assertEquals('i woz here', $cookieJar->get('cookieExisting', false)); //check we can get all cookies $this->assertEquals(array('cookieExisting' => 'i woz changed', 'cookieNew' => 'i am new'), $cookieJar->getAll()); //check we can get all original cookies $this->assertEquals(array('cookieExisting' => 'i woz here'), $cookieJar->getAll(false)); }