From eff2d7f6131abcff15a0a4d254fb18576d4eede5 Mon Sep 17 00:00:00 2001 From: Tom Witkowski Date: Sun, 21 Jun 2020 18:23:39 +0200 Subject: [PATCH] fix test and add exception test --- tests/Features/Macro.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/Features/Macro.php b/tests/Features/Macro.php index 7ba8c127..bb230e19 100644 --- a/tests/Features/Macro.php +++ b/tests/Features/Macro.php @@ -5,8 +5,16 @@ use PHPUnit\Framework\TestCase; uses(Macroable::class); -it('can call chained macro method')->macro('bar', function () { - assertInstanceOf(TestCase::class, $this); +beforeEach(function () { + $this->macro('bar', function () { + assertInstanceOf(TestCase::class, $this); - return $this; -})->bar(); + return $this; + }); +}); + +it('can call chained macro method')->bar(); + +it('will throw exception from call if no macro exists') + ->throws(BadMethodCallException::class) + ->foo();