Skip to content

Instantly share code, notes, and snippets.

@tommymarshall
Created April 22, 2016 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommymarshall/38772fd20bc52693d4d96b4946bcd8bc to your computer and use it in GitHub Desktop.
Save tommymarshall/38772fd20bc52693d4d96b4946bcd8bc to your computer and use it in GitHub Desktop.
<?php
protected function assertCookie($key, $value)
{
$headers = new Collection($this->response->headers->allPreserveCase());
$cookies = new Collection($headers->get('Set-Cookie', []));
$matches = $cookies->filter(function($raw_cookie) use ($key, $value) {
list($raw_value) = explode('; ', $raw_cookie);
list($set_name, $set_value) = explode('=', $raw_value);
if ($set_name == $key && $set_value == $value) {
return true;
}
});
$this->assertCount(1, $matches, "Could not find cookie for '{$key}' / '{$value}'");
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment