passes($this->faker->word(), $this->faker->url())); } /** * The Resource Link Format Rule shall pass for sites with no expected pattern. * * @return void */ public function testPassesForNoPattern(): void { $rule = new ResourceLinkFormatRule(ResourceSite::OFFICIAL_SITE()); static::assertTrue($rule->passes($this->faker->word(), $this->faker->url())); } /** * The Resource Link Format Rule shall pass for anime resources. * * @return void */ public function testPassesForAnimeResource(): void { $site = Arr::random([ ResourceSite::TWITTER(), ResourceSite::ANIDB(), ResourceSite::ANILIST(), ResourceSite::ANIME_PLANET(), ResourceSite::ANN(), ResourceSite::KITSU(), ResourceSite::MAL(), ]); $url = ResourceSite::formatAnimeResourceLink($site, $this->faker->randomDigitNotNull(), $this->faker->word()); $rule = new ResourceLinkFormatRule($site); static::assertTrue($rule->passes($this->faker->word(), $url)); } /** * The Resource Link Format Rule shall pass for artist resources. * * @return void */ public function testPassesForArtistResource(): void { $site = Arr::random([ ResourceSite::TWITTER(), ResourceSite::ANIDB(), ResourceSite::ANILIST(), ResourceSite::ANIME_PLANET(), ResourceSite::ANN(), ResourceSite::MAL(), ]); $url = ResourceSite::formatArtistResourceLink($site, $this->faker->randomDigitNotNull(), $this->faker->word()); $rule = new ResourceLinkFormatRule($site); static::assertTrue($rule->passes($this->faker->word(), $url)); } /** * The Resource Link Format Rule shall pass for studio resources. * * @return void */ public function testPassesForStudioResource(): void { $site = Arr::random([ ResourceSite::TWITTER(), ResourceSite::ANIDB(), ResourceSite::ANILIST(), ResourceSite::ANIME_PLANET(), ResourceSite::ANN(), ResourceSite::MAL(), ]); $url = ResourceSite::formatStudioResourceLink($site, $this->faker->randomDigitNotNull(), $this->faker->word()); $rule = new ResourceLinkFormatRule($site); static::assertTrue($rule->passes($this->faker->word(), $url)); } /** * The Resource Link Format Rule shall fail for trailing slashes in URLs with defined patterns. * * @return void */ public function testFailsForTrailingSlash(): void { $site = Arr::random([ ResourceSite::TWITTER(), ResourceSite::ANIDB(), ResourceSite::ANILIST(), ResourceSite::ANIME_PLANET(), ResourceSite::ANN(), ResourceSite::KITSU(), ResourceSite::MAL(), ]); $url = ResourceSite::formatAnimeResourceLink($site, $this->faker->randomDigitNotNull(), $this->faker->word()); $url = Str::of($url) ->append('/') ->__toString(); $rule = new ResourceLinkFormatRule($site); static::assertFalse($rule->passes($this->faker->word(), $url)); } }