Update RedirectRuleHandlerTest

This commit is contained in:
Alejandro Celaya 2024-11-13 10:00:36 +01:00
parent b5b5f92eda
commit f2371b6124
2 changed files with 10 additions and 2 deletions

View File

@ -117,6 +117,7 @@ class RedirectRuleHandlerTest extends TestCase
'Query param name?' => 'foo',
'Query param value?' => 'bar',
'IP address, CIDR block or wildcard-pattern (1.2.*.*)' => '1.2.3.4',
'Country code to match?' => 'FR',
default => '',
},
);
@ -165,6 +166,10 @@ class RedirectRuleHandlerTest extends TestCase
true,
];
yield 'IP address' => [RedirectConditionType::IP_ADDRESS, [RedirectCondition::forIpAddress('1.2.3.4')]];
yield 'Geolocation country code' => [
RedirectConditionType::GEOLOCATION_COUNTRY_CODE,
[RedirectCondition::forGeolocationCountryCode('FR')],
];
}
#[Test]

View File

@ -97,8 +97,11 @@ class RedirectConditionTest extends TestCase
}
#[Test, DataProvider('provideVisits')]
public function matchesGeolocationCountryCode(Location|null $location, string $countryCodeToMatch, bool $expected): void
{
public function matchesGeolocationCountryCode(
Location|null $location,
string $countryCodeToMatch,
bool $expected,
): void {
$request = ServerRequestFactory::fromGlobals()->withAttribute(Location::class, $location);
$result = RedirectCondition::forGeolocationCountryCode($countryCodeToMatch)->matchesRequest($request);