/** * @dataProvider getMatchingCookiesDataProvider */ public function testReturnsCookiesMatchingRequests($url, $cookies) { $bag = array(new Cookie(array('name' => 'foo', 'value' => 'bar', 'domain' => 'example.com', 'path' => '/', 'max_age' => '86400', 'port' => array(443, 8080), 'version' => '1', 'secure' => true)), new Cookie(array('name' => 'baz', 'value' => 'foobar', 'domain' => 'example.com', 'path' => '/', 'max_age' => '86400', 'port' => array(80, 8080), 'version' => '1', 'secure' => true)), new Cookie(array('name' => 'test', 'value' => '123', 'domain' => 'www.foobar.com', 'path' => '/path/', 'discard' => true)), new Cookie(array('name' => 'muppet', 'value' => 'cookie_monster', 'domain' => '.y.example.com', 'path' => '/acme/', 'comment' => 'Comment goes here...', 'expires' => time() + 86400)), new Cookie(array('name' => 'googoo', 'value' => 'gaga', 'domain' => '.example.com', 'path' => '/test/acme/', 'max_age' => 1500, 'version' => 2))); foreach ($bag as $cookie) { $this->jar->add($cookie); } $request = new Request('GET', $url); $results = $this->jar->getMatchingCookies($request); $this->assertEquals(count($results), count($cookies)); foreach ($cookies as $i) { $this->assertContains($bag[$i], $results); } }