public function test_add() { $headers = new HttpHeaders(['cookie' => 'foo=bar;yolo=swag; bar=foo;']); $request = new HttpRequest(null, null, $headers); $jar = new CookieJar($request); $jar->set('xx', 'yy'); $this->assertEquals(1, count($headers->get('cookie'))); $this->assertEquals('yy', $jar->get('xx')); $this->assertEquals(1, count($headers->get('cookie'))); }
public function test_getters_and_setters() { $headers = new HttpHeaders(); $headers->add('yolo', 'swag'); $headers->set('yolo', 'bar'); $headers->add('bar', 'foo'); $headers->add('bar', 'baz'); $this->assertEquals(['bar'], $headers->get('yolo')); $this->assertEquals('bar', $headers->find('yolo')); $this->assertEquals('baz', $headers->find('bar')); $this->assertEquals(['foo', 'baz'], $headers->get('bar')); $this->assertTrue($headers->has('yolo')); $this->assertTrue($headers->has('bar')); $this->assertFalse($headers->has('foo')); $headers->add('yolo', 'yolo'); $this->assertEquals(['bar', 'yolo'], $headers->get('yolo')); $this->assertEquals('yolo', $headers->find('yolo')); $headers->remove('yolo'); $this->assertEquals([], $headers->get('yolo')); $this->assertEquals('aa', $headers->find('bb', 'aa')); }