feat: not.toHaveSuspiciousCharacters

This commit is contained in:
Nuno Maduro
2025-07-26 07:47:00 -06:00
parent 66e59efec6
commit 4c88590b89
5 changed files with 30 additions and 11 deletions

View File

@ -897,16 +897,9 @@ final class Expectation
/**
* Asserts that the source code of the given expectation target does not include suspicious characters.
*/
public function toNotIncludeSuspiciousCharacters(): ArchExpectation
public function toHaveSuspiciousCharacters(): ArchExpectation
{
$checker = new Spoofchecker();
return Targeted::make(
$this,
fn (ObjectDescription $object) => ! $checker->isSuspicious(file_get_contents($object->path)),
'to not include suspicious characters',
FileLineFinder::where(fn (string $line) => $checker->isSuspicious($line)),
);
throw InvalidExpectation::fromMethods(['toHaveSuspiciousCharacters']);
}
/**