From 4fd06c9b4da8220a2d8087cfe41a2aef689fa393 Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Wed, 7 Aug 2024 21:19:25 +0100 Subject: [PATCH] add assign to tolerated words --- src/Config/tolerated.php | 3 +- src/Expectations/Profanity.php | 2 + tests/Fixtures/HasNoProfanity.php | 63 +++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/Config/tolerated.php b/src/Config/tolerated.php index ff186fc..a3b273c 100644 --- a/src/Config/tolerated.php +++ b/src/Config/tolerated.php @@ -9,5 +9,6 @@ 'start', 'object', 'parse', - 'password' + 'password', + 'assign' ]; diff --git a/src/Expectations/Profanity.php b/src/Expectations/Profanity.php index 8c7723a..9eb013e 100644 --- a/src/Expectations/Profanity.php +++ b/src/Expectations/Profanity.php @@ -25,6 +25,8 @@ function (ObjectDescription $object) use (&$foundWords, $excluding, $including): $foundWords = array_filter($words, fn ($word): bool => preg_match('/'.preg_quote($word, '/').'/i', $fileContents) === 1); + dd($foundWords); + return $foundWords === []; }, 'to not use profanity', diff --git a/tests/Fixtures/HasNoProfanity.php b/tests/Fixtures/HasNoProfanity.php index 968a8c0..54849f3 100644 --- a/tests/Fixtures/HasNoProfanity.php +++ b/tests/Fixtures/HasNoProfanity.php @@ -6,8 +6,63 @@ class HasNoProfanity { - public function __construct( - public string $name, - public string $description, - ) {} + /** + * The application's global HTTP middleware stack. + * + * These middleware are run during every request to your application. + * + * @var array + */ + protected $middleware = [ + // \App\Http\Middleware\TrustHosts::class, + \App\Http\Middleware\TrustProxies::class, + \Illuminate\Http\Middleware\HandleCors::class, + \App\Http\Middleware\PreventRequestsDuringMaintenance::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array> + */ + protected $middlewareGroups = [ + 'web' => [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class . ':api', + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + ]; + + /** + * The application's middleware aliases. + * + * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. + * + * @var array + */ + protected $middlewareAliases = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, + 'signed' => \App\Http\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + ]; }