From d89b010fb9b7cfdf378f14f00402f39d549712b9 Mon Sep 17 00:00:00 2001 From: Caleb Porzio Date: Thu, 8 Nov 2018 11:25:58 -0500 Subject: [PATCH 1/2] Make CookieJar macroable --- src/Illuminate/Cookie/CookieJar.php | 3 ++- tests/Cookie/CookieTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Cookie/CookieJar.php b/src/Illuminate/Cookie/CookieJar.php index abf23fd87933..5c3ca13426ec 100755 --- a/src/Illuminate/Cookie/CookieJar.php +++ b/src/Illuminate/Cookie/CookieJar.php @@ -6,10 +6,11 @@ use Illuminate\Support\InteractsWithTime; use Symfony\Component\HttpFoundation\Cookie; use Illuminate\Contracts\Cookie\QueueingFactory as JarContract; +use Illuminate\Support\Traits\Macroable; class CookieJar implements JarContract { - use InteractsWithTime; + use InteractsWithTime, Macroable; /** * The default path (if specified). diff --git a/tests/Cookie/CookieTest.php b/tests/Cookie/CookieTest.php index d37442e19f2b..8ee3bee5e716 100755 --- a/tests/Cookie/CookieTest.php +++ b/tests/Cookie/CookieTest.php @@ -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'), [ From a09986d926888c144861a32da9284dc6c1c83c59 Mon Sep 17 00:00:00 2001 From: Caleb Porzio Date: Thu, 8 Nov 2018 11:32:14 -0500 Subject: [PATCH 2/2] Move use statement --- src/Illuminate/Cookie/CookieJar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Cookie/CookieJar.php b/src/Illuminate/Cookie/CookieJar.php index 5c3ca13426ec..5d28510e3937 100755 --- a/src/Illuminate/Cookie/CookieJar.php +++ b/src/Illuminate/Cookie/CookieJar.php @@ -3,10 +3,10 @@ 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; -use Illuminate\Support\Traits\Macroable; class CookieJar implements JarContract {