diff --git a/tests/Carbon/DiffTest.php b/tests/Carbon/DiffTest.php index ebe4e574e7..4c68171a16 100644 --- a/tests/Carbon/DiffTest.php +++ b/tests/Carbon/DiffTest.php @@ -16,9 +16,9 @@ use Carbon\Carbon; use Carbon\CarbonInterface; use Carbon\CarbonInterval; +use Carbon\Exceptions\InvalidFormatException; use Closure; use DateTime; -use Exception; use InvalidArgumentException; use Tests\AbstractTestCase; @@ -1577,7 +1577,7 @@ public function testDiffWithInvalidObject() public function testDiffForHumansWithIncorrectDateTimeStringWhichIsNotACarbonInstance() { - $this->expectExceptionObject(new Exception( + $this->expectExceptionObject(new InvalidFormatException( 'Failed to parse time string (2018-04-13-08:00:00) at position 16' )); diff --git a/tests/CarbonImmutable/DiffTest.php b/tests/CarbonImmutable/DiffTest.php index 2629509307..a50086eb35 100644 --- a/tests/CarbonImmutable/DiffTest.php +++ b/tests/CarbonImmutable/DiffTest.php @@ -16,9 +16,9 @@ use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use Carbon\CarbonInterval; +use Carbon\Exceptions\InvalidFormatException; use Closure; use DateTime; -use Exception; use InvalidArgumentException; use Tests\AbstractTestCase; @@ -1532,10 +1532,9 @@ public function testDiffWithInvalidObject() public function testDiffForHumansWithIncorrectDateTimeStringWhichIsNotACarbonInstance() { - $this->expectException(Exception::class); - $this->expectExceptionMessage( + $this->expectExceptionObject(new InvalidFormatException( 'Failed to parse time string (2018-04-13-08:00:00) at position 16' - ); + )); $mar13 = Carbon::parse('2018-03-13'); $mar13->diffForHumans('2018-04-13-08:00:00'); diff --git a/tests/CarbonInterval/CreateFromFormatTest.php b/tests/CarbonInterval/CreateFromFormatTest.php index 60eacf87ad..b8d717251d 100644 --- a/tests/CarbonInterval/CreateFromFormatTest.php +++ b/tests/CarbonInterval/CreateFromFormatTest.php @@ -57,6 +57,7 @@ public function testInvalidSubstitute() "Allowed substitutes for interval formats are y, Y, o, m, n, W, d, j, z, h, g, H, G, i, s, u, v\n". 'See https://php.net/manual/en/function.date.php for their meaning' ); + $this->expectExceptionCode(0); CarbonInterval::createFromFormat('N', '4'); }