Skip to content

Commit

Permalink
Rename KeywordBlacklist rule
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed May 4, 2024
1 parent bc5b248 commit 1f1f7ba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Livewire/Validation/ValidateCustomKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Rule/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 1f1f7ba

Please sign in to comment.