Add toNotIncludeSuspiciousCharacters() expectation

This commit is contained in:
Morten Scheel
2024-10-04 13:44:10 +02:00
committed by GitHub
parent 1e0bb88b73
commit dd7d150caa

View File

@ -885,6 +885,21 @@ final class Expectation
return ToUseNothing::make($this); return ToUseNothing::make($this);
} }
/**
* Asserts that the source code of the given expectation target does not include suspicious characters.
*/
public function toNotIncludeSuspiciousCharacters(): 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)),
);
}
/** /**
* Not supported. * Not supported.
*/ */