value); if ($domain !== null) { $url = 'https://'.$domain; } $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $site->value], [$attribute => new ResourceSiteMatchesLinkRule($url)], ); static::assertTrue($validator->passes()); } /** * The Resource Site Matches Link Rule shall return true if the site does not have a domain. * * @return void */ public function testResourceSiteDomainRuleOfficialPasses(): void { $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => ResourceSite::OFFICIAL_SITE->value], [$attribute => new ResourceSiteMatchesLinkRule($this->faker->url())], ); static::assertTrue($validator->passes()); } /** * The Resource Site Matches Link Rule shall return false if the site does not match the link. * * @return void */ public function testResourceSiteDomainRuleFails(): void { $site = null; while ($site === null) { $siteCandidate = Arr::random(ResourceSite::cases()); if ($siteCandidate !== ResourceSite::OFFICIAL_SITE) { $site = $siteCandidate; } } $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $site->value], [$attribute => new ResourceSiteMatchesLinkRule($this->faker->url())], ); static::assertFalse($validator->passes()); } }