This repository was archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHeaderAccessControlMaxAgeTest.php
More file actions
90 lines (68 loc) · 2.27 KB
/
HeaderAccessControlMaxAgeTest.php
File metadata and controls
90 lines (68 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php declare(strict_types=1);
namespace Sunrise\Http\Header\Tests;
use PHPUnit\Framework\TestCase;
use Sunrise\Http\Header\HeaderInterface;
use Sunrise\Http\Header\HeaderAccessControlMaxAge;
class HeaderAccessControlMaxAgeTest extends TestCase
{
public function testContracts()
{
$header = new HeaderAccessControlMaxAge(-1);
$this->assertInstanceOf(HeaderInterface::class, $header);
}
public function testFieldName()
{
$header = new HeaderAccessControlMaxAge(-1);
$this->assertSame('Access-Control-Max-Age', $header->getFieldName());
}
public function testFieldValue()
{
$header = new HeaderAccessControlMaxAge(-1);
$this->assertSame('-1', $header->getFieldValue());
}
/**
* @dataProvider validValueDataProvider
*/
public function testValidValue(int $validValue)
{
$header = new HeaderAccessControlMaxAge($validValue);
$this->assertSame((string) $validValue, $header->getFieldValue());
}
public function validValueDataProvider() : array
{
return [[-1], [1], [2]];
}
/**
* @dataProvider invalidValueDataProvider
*/
public function testInvalidValue(int $invalidValue)
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(sprintf(
'The value "%d" for the header "Access-Control-Max-Age" is not valid',
$invalidValue
));
new HeaderAccessControlMaxAge($invalidValue);
}
public function invalidValueDataProvider() : array
{
return [[-3], [-2], [0]];
}
public function testBuild()
{
$header = new HeaderAccessControlMaxAge(-1);
$expected = \sprintf('%s: %s', $header->getFieldName(), $header->getFieldValue());
$this->assertSame($expected, $header->__toString());
}
public function testIterator()
{
$header = new HeaderAccessControlMaxAge(-1);
$iterator = $header->getIterator();
$iterator->rewind();
$this->assertSame($header->getFieldName(), $iterator->current());
$iterator->next();
$this->assertSame($header->getFieldValue(), $iterator->current());
$iterator->next();
$this->assertFalse($iterator->valid());
}
}