/** * Test we can get all matching cookies for a request, and return as strings array / concat */ public function testGetMatchingCookiesAsStrings() { $jar = new HTTP\CookieJar(); $cookies = array(HTTP\Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), HTTP\Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), HTTP\Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), HTTP\Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), HTTP\Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), HTTP\Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), HTTP\Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), HTTP\Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600))); foreach ($cookies as $cookie) { $jar->addCookie($cookie); } $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8'); $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, HTTP\CookieJar::COOKIE_STRING_ARRAY); $this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not'); $this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string'); $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, HTTP\CookieJar::COOKIE_STRING_CONCAT); $this->assertType('string', $cookies, '$cookies is expected to be a string'); }