Finalize logic to dynamically match accept language rules

This commit is contained in:
Alejandro Celaya
2024-02-26 19:58:46 +01:00
parent 89a987d03a
commit db02d9f1ba
5 changed files with 65 additions and 10 deletions

View File

@@ -50,9 +50,7 @@ class RedirectTest extends ApiTestCase
];
yield 'rule: english and foo' => [
[
RequestOptions::HEADERS => [
'Accept-Language' => 'en-UK',
],
RequestOptions::HEADERS => ['Accept-Language' => 'en-UK'],
RequestOptions::QUERY => ['foo' => 'bar'],
],
'https://example.com/english-and-foo-query?foo=bar',
@@ -63,11 +61,23 @@ class RedirectTest extends ApiTestCase
],
'https://example.com/multiple-query-params?foo=bar&hello=world',
];
yield 'rule: english' => [
yield 'rule: british english' => [
[
RequestOptions::HEADERS => ['Accept-Language' => 'en-UK'],
],
'https://example.com/only-english',
];
yield 'rule: english' => [
[
RequestOptions::HEADERS => ['Accept-Language' => 'en'],
],
'https://example.com/only-english',
];
yield 'rule: complex matching accept language' => [
[
RequestOptions::HEADERS => ['Accept-Language' => 'fr-FR, es;q=08, en;q=0.5, *;q=0.2'],
],
'https://example.com/only-english',
];
}
}