Open Monograph Press
3.3.0
HeaderComparisonTest.php
1
<?php
2
3
namespace
Guzzle\Tests\Message
;
4
5
use
Guzzle\Common\Collection
;
6
use
Guzzle\Tests\Http\Message\HeaderComparison
;
7
8
class
HeaderComparisonTest
extends
\Guzzle\Tests\GuzzleTestCase
9
{
10
public
function
filterProvider
()
11
{
12
return
array(
13
14
// Headers match
15
array(array(
16
'Content-Length'
=>
'Foo'
17
), array(
18
'Content-Length'
=>
'Foo'
19
),
false
),
20
21
// Missing header
22
array(array(
23
'X-Foo'
=>
'Bar'
24
), array(), array(
25
'- X-Foo'
=>
'Bar'
26
)),
27
28
// Extra headers is present
29
array(array(
30
'X-Foo'
=>
'Bar'
31
), array(
32
'X-Foo'
=>
'Bar'
,
33
'X-Baz'
=>
'Jar'
34
), array(
35
'+ X-Baz'
=>
'Jar'
36
)),
37
38
// Header is present but must be absent
39
array(array(
40
'!X-Foo'
=>
'*'
41
), array(
42
'X-Foo'
=>
'Bar'
43
), array(
44
'++ X-Foo'
=>
'Bar'
45
)),
46
47
// Different values
48
array(array(
49
'X-Foo'
=>
'Bar'
50
), array(
51
'X-Foo'
=>
'Baz'
52
), array(
53
'X-Foo'
=>
'Baz != Bar'
54
)),
55
56
// Wildcard search passes
57
array(array(
58
'X-Foo'
=>
'*'
59
), array(
60
'X-Foo'
=>
'Bar'
61
),
false
),
62
63
// Wildcard search fails
64
array(array(
65
'X-Foo'
=>
'*'
66
), array(), array(
67
'- X-Foo'
=>
'*'
68
)),
69
70
// Ignore extra header if present
71
array(array(
72
'X-Foo'
=>
'*'
,
73
'_X-Bar'
=>
'*'
,
74
), array(
75
'X-Foo'
=>
'Baz'
,
76
'X-Bar'
=>
'Jar'
77
),
false
),
78
79
// Ignore extra header if present and is not
80
array(array(
81
'X-Foo'
=>
'*'
,
82
'_X-Bar'
=>
'*'
,
83
), array(
84
'X-Foo'
=>
'Baz'
85
),
false
),
86
87
// Case insensitive
88
array(array(
89
'X-Foo'
=>
'*'
,
90
'_X-Bar'
=>
'*'
,
91
), array(
92
'x-foo'
=>
'Baz'
,
93
'x-BAR'
=>
'baz'
94
),
false
),
95
96
// Case insensitive with collection
97
array(array(
98
'X-Foo'
=>
'*'
,
99
'_X-Bar'
=>
'*'
,
100
),
new
Collection
(array(
101
'x-foo'
=>
'Baz'
,
102
'x-BAR'
=>
'baz'
103
)),
false
),
104
);
105
}
106
110
public
function
testComparesHeaders
($filters, $headers, $result)
111
{
112
$compare =
new
HeaderComparison
();
113
$this->assertEquals($result, $compare->compare($filters, $headers));
114
}
115
}
Guzzle\Tests\Message\HeaderComparisonTest\filterProvider
filterProvider()
Definition:
HeaderComparisonTest.php:10
Guzzle\Tests\GuzzleTestCase
Definition:
GuzzleTestCase.php:22
Guzzle\Tests\Message
Definition:
HeaderComparisonTest.php:3
Guzzle\Tests\Message\HeaderComparisonTest\testComparesHeaders
testComparesHeaders($filters, $headers, $result)
Definition:
HeaderComparisonTest.php:110
Guzzle\Tests\Http\Message\HeaderComparison
Definition:
HeaderComparison.php:11
Guzzle\Tests\Message\HeaderComparisonTest
Definition:
HeaderComparisonTest.php:8
Guzzle\Common\Collection
Definition:
Collection.php:11
plugins
paymethod
paypal
lib
vendor
guzzle
guzzle
tests
Guzzle
Tests
Http
Message
HeaderComparisonTest.php
Generated on Fri Aug 28 2020 14:52:35 for Open Monograph Press by
1.8.17