Skip to content

Commit

Permalink
test: resources link format test (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Oct 31, 2023
1 parent 708e6e4 commit 8279465
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Unit/Rules/Wiki/Resource/AnimeResourceLinkFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,35 @@ public function testFailsForArtistResource(): void
static::assertFalse($validator->passes());
}

/**
* The Anime Resource Link Format Rule shall fail for song resources.
*
* @return void
*/
public function testFailsForSongResource(): void
{
/** @var ResourceSite $site */
$site = Arr::random([
ResourceSite::ANIDB,
ResourceSite::ANILIST,
ResourceSite::ANIME_PLANET,
ResourceSite::ANN,
ResourceSite::MAL,
ResourceSite::YOUTUBE,
]);

$url = $site->formatSongResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());

$attribute = $this->faker->word();

$validator = Validator::make(
[$attribute => $url],
[$attribute => new AnimeResourceLinkFormatRule($site)],
);

static::assertFalse($validator->passes());
}

/**
* The Anime Resource Link Format Rule shall fail for studio resources.
*
Expand Down
30 changes: 30 additions & 0 deletions tests/Unit/Rules/Wiki/Resource/ArtistResourceLinkFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,36 @@ public function testFailsForAnimeResource(): void
static::assertFalse($validator->passes());
}

/**
* The Artist Resource Link Format Rule shall fail for song resources.
*
* @return void
*/
public function testFailsForSongResource(): void
{
/** @var ResourceSite $site */
$site = Arr::random([
ResourceSite::ANIDB,
ResourceSite::ANILIST,
ResourceSite::ANIME_PLANET,
ResourceSite::ANN,
ResourceSite::MAL,
ResourceSite::SPOTIFY,
ResourceSite::YOUTUBE,
]);

$url = $site->formatSongResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());

$attribute = $this->faker->word();

$validator = Validator::make(
[$attribute => $url],
[$attribute => new ArtistResourceLinkFormatRule($site)],
);

static::assertFalse($validator->passes());
}

/**
* The Artist Resource Link Format Rule shall fail for studio resources.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Rules/Wiki/Resource/ResourceLinkFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ public function testFailsForTrailingSlash(): void
ResourceSite::ANN,
ResourceSite::KITSU,
ResourceSite::MAL,
ResourceSite::SPOTIFY,
ResourceSite::YOUTUBE,
ResourceSite::YOUTUBE_MUSIC,
ResourceSite::APPLE_MUSIC,
ResourceSite::AMAZON_MUSIC,
]);

$url = $site->formatAnimeResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());
Expand Down
31 changes: 31 additions & 0 deletions tests/Unit/Rules/Wiki/Resource/SongResourceLinkFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function testFailsForAnimeResource(): void
ResourceSite::ANIME_PLANET,
ResourceSite::ANN,
ResourceSite::MAL,
ResourceSite::YOUTUBE,
]);

$url = $site->formatAnimeResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());
Expand All @@ -153,6 +154,36 @@ public function testFailsForAnimeResource(): void
static::assertFalse($validator->passes());
}

/**
* The Song Resource Link Format Rule shall fail for artist resources.
*
* @return void
*/
public function testFailsForArtistResource(): void
{
/** @var ResourceSite $site */
$site = Arr::random([
ResourceSite::ANIDB,
ResourceSite::ANILIST,
ResourceSite::ANIME_PLANET,
ResourceSite::ANN,
ResourceSite::MAL,
ResourceSite::SPOTIFY,
ResourceSite::YOUTUBE,
]);

$url = $site->formatArtistResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());

$attribute = $this->faker->word();

$validator = Validator::make(
[$attribute => $url],
[$attribute => new SongResourceLinkFormatRule($site)],
);

static::assertFalse($validator->passes());
}

/**
* The Song Resource Link Format Rule shall fail for studio resources.
*
Expand Down
27 changes: 27 additions & 0 deletions tests/Unit/Rules/Wiki/Resource/StudioResourceLinkFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,31 @@ public function testFailsForArtistResource(): void

static::assertFalse($validator->passes());
}

/**
* The Studio Resource Link Format Rule shall fail for song resources.
*
* @return void
*/
public function testFailsForSongResource(): void
{
/** @var ResourceSite $site */
$site = Arr::random([
ResourceSite::ANILIST,
ResourceSite::ANIME_PLANET,
ResourceSite::ANN,
ResourceSite::MAL,
]);

$url = $site->formatSongResourceLink($this->faker->randomDigitNotNull(), $this->faker->word());

$attribute = $this->faker->word();

$validator = Validator::make(
[$attribute => $url],
[$attribute => new StudioResourceLinkFormatRule($site)],
);

static::assertFalse($validator->passes());
}
}

0 comments on commit 8279465

Please sign in to comment.