/** * @group testCookie */ public function testCookie() { $test_cookie_data = array('name' => 'name', 'value' => 'value', 'expiry' => null, 'path' => '/path', 'domain' => 'whatever.com', 'secure' => true, 'httponly' => true); $test_cookie = new ResponseCookie($test_cookie_data['name'], $test_cookie_data['value'], $test_cookie_data['expiry'], $test_cookie_data['path'], $test_cookie_data['domain'], $test_cookie_data['secure'], $test_cookie_data['httponly']); $response = new Response(); // Make sure the cookies are initially empty $this->assertEmpty($response->cookies()->all()); // Set a cookies $response->cookie($test_cookie_data['name'], $test_cookie_data['value'], $test_cookie_data['expiry'], $test_cookie_data['path'], $test_cookie_data['domain'], $test_cookie_data['secure'], $test_cookie_data['httponly']); $this->assertNotEmpty($response->cookies()->all()); $the_cookie = $response->cookies()->get($test_cookie_data['name']); $this->assertNotNull($the_cookie); $this->assertTrue($the_cookie instanceof ResponseCookie); $this->assertSame($test_cookie_data['name'], $the_cookie->getName()); $this->assertSame($test_cookie_data['value'], $the_cookie->getValue()); $this->assertSame($test_cookie_data['path'], $the_cookie->getPath()); $this->assertSame($test_cookie_data['domain'], $the_cookie->getDomain()); $this->assertSame($test_cookie_data['secure'], $the_cookie->getSecure()); $this->assertSame($test_cookie_data['httponly'], $the_cookie->getHttpOnly()); $this->assertNotNull($the_cookie->getExpire()); }
/** * Testing cookies is exactly like testing headers * ... So, yea. */ public function testSendCookies() { $response = new Response(); $response->cookies()->set('test', 'woot!'); $response->cookies()->set('Cookie name!', 'wtf?'); $response->sendCookies(); $this->expectOutputString(null); }