Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Make CookieJar macroable #26445

Merged
merged 2 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace Illuminate\Cookie;

use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\InteractsWithTime;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;

class CookieJar implements JarContract
{
use InteractsWithTime;
use InteractsWithTime, Macroable;

/**
* The default path (if specified).
Expand Down
9 changes: 9 additions & 0 deletions tests/Cookie/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public function testUnqueue()
$this->assertEmpty($cookie->getQueuedCookies());
}

public function testCookieJarIsMacroable()
{
$cookie = $this->getCreator();
$cookie->macro('foo', function () {
return 'bar';
});
$this->assertEquals('bar', $cookie->foo());
}

public function getCreator()
{
return new CookieJar(Request::create('/foo', 'GET'), [
Expand Down