You can't. Cookie::get() dispatches to Request::cookie, and per the docs Request isn't to be mocked. The way I've used is:
public function test_something() {
$this->client->getCookieJar()->set(
new \Symfony\Component\BrowserKit\Cookie('foo', 'bar')
);
$this->call('GET', '/a/route');
$this->assertSame('bar', \Cookie::get('foo'));
}
You must absolutely call the route before the \Cookie::get assertion will pass BECAUSE cookies do not exist until given by the client.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community