Skip to content

Commit 8c2ecb9

Browse files
committed
- tests updated
1 parent 394ef27 commit 8c2ecb9

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

Tests/AcceptLanguageHeaderTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
class AcceptLanguageHeaderTest extends TestCase
99
{
1010
/**
11-
* @dataProvider dataForAsteriskSupport
11+
* @dataProvider dataForSupportedLanguagesWithAsterisk
1212
*/
1313
public function test_match_with_asterisk($accept, $expect, $quality)
1414
{
15-
$this->markTestSkipped('WIP...');
1615
$negotiator = (new AcceptHeaderNegotiator('*'))->match($accept);
1716

1817
$this->assertSame($expect, $negotiator->value(), 'Expects ' . $expect);
@@ -24,7 +23,6 @@ public function test_match_with_asterisk($accept, $expect, $quality)
2423
*/
2524
public function test_with_preferred_languages($accept, $expect, $quality)
2625
{
27-
$this->markTestIncomplete('WIP...');
2826
$negotiator = (new AcceptHeaderNegotiator('de,fr,en'))->match($accept);
2927

3028
$this->assertSame($expect, $negotiator->value(), 'Expects ' . $expect);
@@ -37,7 +35,7 @@ public function test_empty_accept_and_support_headers()
3735
$this->assertEquals('', $match->value(), 'Empty headers returns empty matched value');
3836
}
3937

40-
public function dataForAsteriskSupport()
38+
public function dataForSupportedLanguagesWithAsterisk()
4139
{
4240
return [
4341
['*;q=0.5, fr;q=0.9, en;q=0.8, de;q=0.7', 'fr', 0.9],
@@ -50,7 +48,7 @@ public function dataForSupportedLanguages()
5048
{
5149
return [
5250
['fr;q=0.7, en;q=0.8, de;q=0.9, *;q=0.5', 'de', 0.9],
53-
['en-US,en;q=0.5', 'en-US', 1.0],
51+
['en-US,en;q=0.5', 'en', 0.5],
5452
['*', 'de', 1.0]
5553
];
5654
}

Tests/HeaderTraitTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@ public function test_get_header_line()
4040
$this->assertSame('baz', $response->getHeaderLine('bar'));
4141
}
4242

43-
public function test_set_header_line_with_invalid_value()
43+
public function test_set_header_line_with_invalid_array_values()
4444
{
4545
$this->expectException(\InvalidArgumentException::class);
4646
$this->expectExceptionCode(HttpStatus::BAD_REQUEST);
4747
$this->expectExceptionMessage('expects a string or array of strings');
48-
$this->SUT->withHeader('foo', [1]);
48+
$this->SUT->withHeader('foo', ['bar', 1]);
49+
}
50+
51+
public function test_set_header_line_with_invalid_scalar_value()
52+
{
53+
$this->expectException(\InvalidArgumentException::class);
54+
$this->expectExceptionCode(HttpStatus::BAD_REQUEST);
55+
$this->expectExceptionMessage('expects a string or array of strings');
56+
$this->SUT->withHeader('foo', 0);
4957
}
5058

5159
public function test_add_header_value()

0 commit comments

Comments
 (0)