This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

hugo.wijdeveld
hugo.wijdeveld

I have a test for a method that sets a cookie, with the name of 'cart' and the value of the cart_id, which is an integer. The following assertion passes:

$this->visit('/')->seeCookie('cart');

But when I want to retrieve the value of the cookie

$cookieValue = Cookie::get('cart');

I end up with a 'null' value.

When I use

$response = $this->call('GET', '/');
dd($response->headers->getCookies()[0]->getValue());

I get the encrypted value of the cookie. (I can use index = 0 in this testing situation, because there will be no other index). More proof that the cookie is really present. But I do need the decrypted value for the rest of my test.

Does anyone know how I can retrieve the cookie value while testing? Or am I making a mistake in setting up my test? F.Y.I.: I do have a functioning script (where cookie:get() does the job it is suposed to do) but I want to have a proper test before refactoring.

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.