/** * Tests sending the cookie jar and that the Nimbles\Http\Cookie\Exception\HeadersAlreadySent * exception is thrown when attempt to send once headers are already sent * @return void */ public function testSend() { $jar = new Cookie\Jar(); $cookie = new Cookie(array('name' => 'test_name', 'value' => 'test value')); $sent = false; $urlencoded = array(); $raw = array(); $cookie->setDelegate('headers_sent', function () use(&$sent) { return $sent; }); $cookie->setDelegate('setcookie', function () use(&$urlencoded) { $urlencoded = func_get_args(); $urlencoded[1] = urlencode($urlencoded[1]); }); $jar[] = $cookie; $this->assertEquals('test value', (string) $jar['test_name']); $jar->send(); $this->assertSame(array('test_name', 'test+value', 0, '/', null, false, false), $urlencoded); $sent = true; $this->setExpectedException('Nimbles\\Http\\Cookie\\Exception\\HeadersAlreadySent'); $jar->send(); }