From 36130eb7a0ba97b6d2710fbabc101525c34481ca Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Fri, 18 Feb 2022 16:40:17 +0100 Subject: [PATCH] adds a failing test --- tests/Features/Expect/toThrow.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Features/Expect/toThrow.php b/tests/Features/Expect/toThrow.php index 434ced44..b5c66abf 100644 --- a/tests/Features/Expect/toThrow.php +++ b/tests/Features/Expect/toThrow.php @@ -58,3 +58,19 @@ test('closure missing parameter', function () { test('closure missing type-hint', function () { expect(function () {})->toThrow(function ($e) {}); })->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.'); + +it('can handle a non-defined exception', function () { + expect(function () { + throw new NonExistingException(); + })->toThrow(NonExistingException::class); +})->throws(Error::class, 'Class "NonExistingException" not found'); + +it('can handle a class not found Error', function () { + expect(function () { + throw new NonExistingException(); + })->toThrow('Class "NonExistingException" not found'); + + expect(function () { + throw new NonExistingException(); + })->toThrow(Error::class, 'Class "NonExistingException" not found'); +});