From 1f1f7ba07b19ba1251fff1f012a86f9d4bd3b20f Mon Sep 17 00:00:00 2001 From: Kei Date: Sun, 5 May 2024 00:38:43 +0700 Subject: [PATCH] Rename KeywordBlacklist rule --- app/Livewire/Validation/ValidateCustomKeyword.php | 2 +- .../{KeywordBlacklist.php => NotBlacklistedKeyword.php} | 2 +- tests/Unit/Rule/UrlTest.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename app/Rules/Url/{KeywordBlacklist.php => NotBlacklistedKeyword.php} (92%) diff --git a/app/Livewire/Validation/ValidateCustomKeyword.php b/app/Livewire/Validation/ValidateCustomKeyword.php index e949f3632..3980f669a 100644 --- a/app/Livewire/Validation/ValidateCustomKeyword.php +++ b/app/Livewire/Validation/ValidateCustomKeyword.php @@ -28,7 +28,7 @@ public function rules() 'keyword' => [ "min:$minLen", "max:$maxLen", 'unique:App\Models\Url', 'lowercase:field', new \App\Rules\AlphaNumHyphen, - new \App\Rules\Url\KeywordBlacklist, + new \App\Rules\Url\NotBlacklistedKeyword, ], ]; } diff --git a/app/Rules/Url/KeywordBlacklist.php b/app/Rules/Url/NotBlacklistedKeyword.php similarity index 92% rename from app/Rules/Url/KeywordBlacklist.php rename to app/Rules/Url/NotBlacklistedKeyword.php index c61420b81..22b8edab2 100644 --- a/app/Rules/Url/KeywordBlacklist.php +++ b/app/Rules/Url/NotBlacklistedKeyword.php @@ -9,7 +9,7 @@ * Check if keyword id is free (ie not already taken, not a URL path, and not * reserved). */ -class KeywordBlacklist implements ValidationRule +class NotBlacklistedKeyword implements ValidationRule { /** * Run the validation rule. diff --git a/tests/Unit/Rule/UrlTest.php b/tests/Unit/Rule/UrlTest.php index cee68f077..bcb59b523 100644 --- a/tests/Unit/Rule/UrlTest.php +++ b/tests/Unit/Rule/UrlTest.php @@ -2,8 +2,8 @@ namespace Tests\Unit\Rule; -use App\Rules\Url\KeywordBlacklist; use App\Rules\Url\NotBlacklistedDomain; +use App\Rules\Url\NotBlacklistedKeyword; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; @@ -78,7 +78,7 @@ public static function domainBlacklistFailDataProvider(): array #[DataProvider('customKeywordBlacklistPassDataProvider')] public function customKeywordBlacklistPass($value): void { - $val = Helper::validator(['foo' => $value], ['foo' => new KeywordBlacklist]); + $val = Helper::validator(['foo' => $value], ['foo' => new NotBlacklistedKeyword]); $this->assertTrue($val->passes()); $this->assertSame([], $val->messages()->messages()); @@ -92,7 +92,7 @@ public function customKeywordBlacklistPass($value): void #[DataProvider('customKeywordContainsRegisteredRouteWillFailDataProvider')] public function customKeywordContainsRegisteredRouteWillFail($value): void { - $val = Helper::validator(['foo' => $value], ['foo' => new KeywordBlacklist]); + $val = Helper::validator(['foo' => $value], ['foo' => new NotBlacklistedKeyword]); $this->assertTrue($val->fails()); $this->assertSame(['foo' => ['Not available.']], $val->messages()->messages()); @@ -103,7 +103,7 @@ public function customKeywordContainsReservedKeywordWillFail(): void $value = 'css'; config(['urlhub.reserved_keyword' => $value]); - $val = Helper::validator(['foo' => $value], ['foo' => new KeywordBlacklist]); + $val = Helper::validator(['foo' => $value], ['foo' => new NotBlacklistedKeyword]); $this->assertTrue($val->fails()); $this->assertSame(['foo' => ['Not available.']], $val->messages()->messages());