Skip to content

Commit ae298f9

Browse files
committed
Improve Item testing
1 parent ddc5b9c commit ae298f9

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/ItemTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ final class ItemTest extends StructuredFieldTest
1616
__DIR__.'/../vendor/httpwg/structured-field-tests/number-generated.json',
1717
__DIR__.'/../vendor/httpwg/structured-field-tests/string.json',
1818
__DIR__.'/../vendor/httpwg/structured-field-tests/string-generated.json',
19+
__DIR__.'/../vendor/httpwg/structured-field-tests/token.json',
20+
__DIR__.'/../vendor/httpwg/structured-field-tests/token-generated.json',
1921
__DIR__.'/../vendor/httpwg/structured-field-tests/item.json',
2022
];
2123

src/TokenTest.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,37 @@
44

55
namespace Bakame\Http\StructuredFields;
66

7+
use PHPUnit\Framework\TestCase;
78
use function var_export;
89

910
/**
1011
* @coversDefaultClass \Bakame\Http\StructuredFields\Token
1112
*/
12-
final class TokenTest extends StructuredFieldTest
13+
final class TokenTest extends TestCase
1314
{
14-
/** @var array|string[] */
15-
protected array $paths = [
16-
__DIR__.'/../vendor/httpwg/structured-field-tests/token.json',
17-
__DIR__.'/../vendor/httpwg/structured-field-tests/token-generated.json',
18-
];
19-
2015
/**
2116
* @test
17+
* @dataProvider invalidTokenString
2218
*/
23-
public function it_will_fail_on_invalid_token_string(): void
19+
public function it_will_fail_on_invalid_token_string(string $httpValue): void
2420
{
2521
$this->expectException(SyntaxError::class);
2622

27-
Token::fromString('a a');
23+
Token::fromString($httpValue);
24+
}
25+
26+
/**
27+
* @return array<array{0:string}>
28+
*/
29+
public function invalidTokenString(): array
30+
{
31+
return [
32+
['a a'],
33+
["a\u0001a"],
34+
['3a'],
35+
['a"a'],
36+
['a,a'],
37+
];
2838
}
2939

3040
/**

0 commit comments

Comments
 (0)