Skip to content

Commit

Permalink
display the file where error was detected
Browse files Browse the repository at this point in the history
  • Loading branch information
faissaloux committed Oct 12, 2024
1 parent 60a688f commit 804eeaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
10 changes: 9 additions & 1 deletion tests/toReturnLowercase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');

0 comments on commit 804eeaa

Please sign in to comment.