From 804eeaa329ac26372abfa1d81de72b7c42a72179 Mon Sep 17 00:00:00 2001 From: faissaloux Date: Sat, 12 Oct 2024 01:14:46 +0100 Subject: [PATCH] display the file where error was detected --- src/Expectation.php | 2 +- tests/toReturnLowercase.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index d73b715..a281454 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -38,7 +38,7 @@ function (int $depth = -1): PestExpectation { continue; } - expect($word)->toBeLowercase("Not lowercase word found: $content[$key]"); + expect($word)->toBeLowercase("Not lowercase word detected: $content[$key] in $file"); } } diff --git a/tests/toReturnLowercase.php b/tests/toReturnLowercase.php index f88ad7b..84d3fd8 100644 --- a/tests/toReturnLowercase.php +++ b/tests/toReturnLowercase.php @@ -35,7 +35,7 @@ it('fails when file does not exist', function (): void { expect('tests/Fixtures/notExist.php') ->toReturnLowercase(); -})->throws(ExpectationFailedException::class); +})->throws(ExpectationFailedException::class, 'tests/Fixtures/notExist.php not found'); it('fails when directory does not exist', function (): void { expect('tests/Fixtures/notExist') @@ -51,3 +51,11 @@ expect('tests/Fixtures/shouldAllBeLowercase') ->toReturnLowercase(); })->throws(ExpectationFailedException::class); + +it('displays word detected', function (): void { + expect('tests/Fixtures/shouldAllBeLowercase')->toReturnLowercase(); +})->throws(ExpectationFailedException::class, 'Not lowercase word detected: loWer'); + +it('displays file where error detected', function (): void { + expect('tests/Fixtures/shouldAllBeLowercase')->toReturnLowercase(); +})->throws(ExpectationFailedException::class, 'notAllLowerCase.php');