From dd7d150caa42880f59de2d37abb93d958532e8c1 Mon Sep 17 00:00:00 2001 From: Morten Scheel Date: Fri, 4 Oct 2024 13:44:10 +0200 Subject: [PATCH] Add toNotIncludeSuspiciousCharacters() expectation --- src/Expectation.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Expectation.php b/src/Expectation.php index ebfd6302..94097ea8 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -885,6 +885,21 @@ public function toUseNothing(): ArchExpectation 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. */