From 8e32b88fc8f251674a86032913a70a24a3cdac02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20A=C5=9Fan?= Date: Sat, 7 Aug 2021 08:22:26 +0300 Subject: [PATCH] add tests --- tests/Features/Exceptions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Features/Exceptions.php b/tests/Features/Exceptions.php index 37eaaeb9..9970c2a9 100644 --- a/tests/Features/Exceptions.php +++ b/tests/Features/Exceptions.php @@ -17,3 +17,23 @@ it('catch exceptions and messages', function () { it('can just define the message', function () { throw new Exception('Something bad happened'); })->throws('Something bad happened'); + +it('not catch exceptions if given condition is false', function () { + $this->assertTrue(true); +})->throwsIf(false, Exception::class); + +it('catch exceptions if given condition is true', function () { + throw new Exception('Something bad happened'); +})->throwsIf(function () { return true; }, Exception::class); + +it('catch exceptions and messages if given condition is true', function () { + throw new Exception('Something bad happened'); +})->throwsIf(true, Exception::class, 'Something bad happened'); + +it('can just define the message if given condition is true', function () { + throw new Exception('Something bad happened'); +})->throwsIf(true, 'Something bad happened'); + +it('can just define the message if given condition is 1', function () { + throw new Exception('Something bad happened'); +})->throwsIf(1, 'Something bad happened');