@@ -14,49 +14,49 @@ class FunctionalConstraintTest extends TestCase
14
14
public function testHasUriCanSucceed ()
15
15
{
16
16
$ request = new Request ('GET ' , '/foo ' );
17
- assertThat ($ request , hasUri ('/foo ' ));
17
+ self :: assertThat ($ request , hasUri ('/foo ' ));
18
18
}
19
19
20
20
public function testHasUriCanFail ()
21
21
{
22
22
$ this ->expectException (AssertionFailedError::class);
23
23
24
24
$ request = new Request ('GET ' , '/foo ' );
25
- assertThat ($ request , hasUri ('/bar ' ));
25
+ self :: assertThat ($ request , hasUri ('/bar ' ));
26
26
}
27
27
28
28
public function testHasHeaderCanSucceedWithPrimitiveValue ()
29
29
{
30
30
$ request = new Request ('GET ' , '/ ' , ['x-foo ' => 'bar ' ]);
31
- assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
31
+ self :: assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
32
32
}
33
33
34
34
public function testHasHeaderCanFailWithPrimitiveValue ()
35
35
{
36
36
$ this ->expectException (AssertionFailedError::class);
37
37
38
38
$ request = new Request ('GET ' , '/ ' , ['x-foo ' => 'baz ' ]);
39
- assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
39
+ self :: assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
40
40
}
41
41
42
42
public function testHasHeaderCanFailWithNonExistingHeader ()
43
43
{
44
44
$ this ->expectException (AssertionFailedError::class);
45
45
46
46
$ request = new Request ('GET ' , '/ ' , []);
47
- assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
47
+ self :: assertThat ($ request , hasHeader ('X-Foo ' , 'bar ' ));
48
48
}
49
49
50
50
public function testHasHeaderCanSucceedWithConstraint ()
51
51
{
52
52
$ request = new Request ('GET ' , '/ ' , ['x-foo ' => 14 ]);
53
- assertThat ($ request , hasHeader ('X-Foo ' , greaterThanOrEqual (10 )));
53
+ self :: assertThat ($ request , hasHeader ('X-Foo ' , self :: greaterThanOrEqual (10 )));
54
54
}
55
55
56
56
public function testHasHeadersCanSucceedWithConstraint ()
57
57
{
58
58
$ request = new Request ('GET ' , '/ ' , ['x-foo ' => 14 , 'content-type ' => 'text/plain ' ]);
59
- assertThat ($ request , hasHeaders ([
59
+ self :: assertThat ($ request , hasHeaders ([
60
60
'X-Foo ' => Assert::greaterThanOrEqual (10 ),
61
61
'Content-Type ' => 'text/plain ' ,
62
62
]));
@@ -67,27 +67,27 @@ public function testHasHeaderCanFailWithConstraint()
67
67
$ this ->expectException (AssertionFailedError::class);
68
68
69
69
$ request = new Request ('GET ' , '/ ' , ['x-foo ' => 4 ]);
70
- assertThat ($ request , hasHeader ('X-Foo ' , greaterThanOrEqual (10 )));
70
+ self :: assertThat ($ request , hasHeader ('X-Foo ' , self :: greaterThanOrEqual (10 )));
71
71
}
72
72
73
73
public function testBodyMatchesCanSucceed ()
74
74
{
75
75
$ request = new Request ('GET ' , '/ ' , [], 'foobar ' );
76
- assertThat ($ request , bodyMatches (equalTo ('foobar ' )));
76
+ self :: assertThat ($ request , bodyMatches (self :: equalTo ('foobar ' )));
77
77
}
78
78
79
79
public function testBodyMatchesCanFail ()
80
80
{
81
81
$ this ->expectException (AssertionFailedError::class);
82
82
83
83
$ request = new Request ('GET ' , '/ ' , [], 'foobar ' );
84
- assertThat ($ request , bodyMatches (equalTo ('barbaz ' )));
84
+ self :: assertThat ($ request , bodyMatches (self :: equalTo ('barbaz ' )));
85
85
}
86
86
87
87
public function testBodyMatchesJsonCanSucceed ()
88
88
{
89
89
$ request = new Request ('GET ' , '/foo ' , ['content-type ' => 'application/json ' ], json_encode (['foo ' => 'bar ' ]));
90
- assertThat ($ request , bodyMatchesJson (['$.foo ' => 'bar ' ]));
90
+ self :: assertThat ($ request , bodyMatchesJson (['$.foo ' => 'bar ' ]));
91
91
}
92
92
93
93
public function dataForRequestMethods ()
@@ -109,55 +109,55 @@ public function dataForRequestMethods()
109
109
*/
110
110
public function testAssertRequestHasMethodCanSucceed ($ method )
111
111
{
112
- assertThat (new Request ($ method , '/ ' ), hasMethod ($ method ));
112
+ self :: assertThat (new Request ($ method , '/ ' ), hasMethod ($ method ));
113
113
}
114
114
115
115
public function testIsGetCanSucceed ()
116
116
{
117
- assertThat (new Request ('GET ' , '/ ' ), isGet ());
117
+ self :: assertThat (new Request ('GET ' , '/ ' ), isGet ());
118
118
}
119
119
120
120
public function testIsGetCanFail ()
121
121
{
122
122
$ this ->expectException (AssertionFailedError::class);
123
123
124
- assertThat (new Request ('POST ' , '/ ' ), isGet ());
124
+ self :: assertThat (new Request ('POST ' , '/ ' ), isGet ());
125
125
}
126
126
127
127
public function testIsPostCanSucceed ()
128
128
{
129
- assertThat (new Request ('POST ' , '/ ' ), isPost ());
129
+ self :: assertThat (new Request ('POST ' , '/ ' ), isPost ());
130
130
}
131
131
132
132
public function testIsPostCanFail ()
133
133
{
134
134
$ this ->expectException (AssertionFailedError::class);
135
135
136
- assertThat (new Request ('GET ' , '/ ' ), isPost ());
136
+ self :: assertThat (new Request ('GET ' , '/ ' ), isPost ());
137
137
}
138
138
139
139
public function testIsPutCanSucceed ()
140
140
{
141
- assertThat (new Request ('PUT ' , '/ ' ), isPut ());
141
+ self :: assertThat (new Request ('PUT ' , '/ ' ), isPut ());
142
142
}
143
143
144
144
public function testIsPutCanFail ()
145
145
{
146
146
$ this ->expectException (AssertionFailedError::class);
147
147
148
- assertThat (new Request ('GET ' , '/ ' ), isPut ());
148
+ self :: assertThat (new Request ('GET ' , '/ ' ), isPut ());
149
149
}
150
150
151
151
public function testIsDeleteCanSucceed ()
152
152
{
153
- assertThat (new Request ('DELETE ' , '/ ' ), isDelete ());
153
+ self :: assertThat (new Request ('DELETE ' , '/ ' ), isDelete ());
154
154
}
155
155
156
156
public function testIsDeleteCanFail ()
157
157
{
158
158
$ this ->expectException (AssertionFailedError::class);
159
159
160
- assertThat (new Request ('POST ' , '/ ' ), isDelete ());
160
+ self :: assertThat (new Request ('POST ' , '/ ' ), isDelete ());
161
161
}
162
162
163
163
public function dataForStatusCodes ()
@@ -175,60 +175,60 @@ public function dataForStatusCodes()
175
175
*/
176
176
public function testHasStatusCanSucceed ($ status )
177
177
{
178
- assertThat (new Response ($ status ), hasStatus ($ status ));
178
+ self :: assertThat (new Response ($ status ), hasStatus ($ status ));
179
179
}
180
180
181
181
public function testHasStatusCanFail ()
182
182
{
183
183
$ this ->expectException (AssertionFailedError::class);
184
184
185
- assertThat (new Response (400 ), hasStatus (200 ));
185
+ self :: assertThat (new Response (400 ), hasStatus (200 ));
186
186
}
187
187
188
188
public function testIsSuccessCanSucceed ()
189
189
{
190
- assertThat (new Response (200 ), isSuccess ());
190
+ self :: assertThat (new Response (200 ), isSuccess ());
191
191
}
192
192
193
193
public function testIsSuccessCanFail ()
194
194
{
195
195
$ this ->expectException (AssertionFailedError::class);
196
196
197
- assertThat (new Response (404 ), isSuccess ());
197
+ self :: assertThat (new Response (404 ), isSuccess ());
198
198
}
199
199
200
200
public function testIsClientErrorCanSucceed ()
201
201
{
202
- assertThat (new Response (404 ), isClientError ());
202
+ self :: assertThat (new Response (404 ), isClientError ());
203
203
}
204
204
205
205
public function testIsClientErrorCanFail ()
206
206
{
207
207
$ this ->expectException (AssertionFailedError::class);
208
208
209
- assertThat (new Response (200 ), isClientError ());
209
+ self :: assertThat (new Response (200 ), isClientError ());
210
210
}
211
211
212
212
public function testIsServerErrorCanSucceed ()
213
213
{
214
- assertThat (new Response (503 ), isServerError ());
214
+ self :: assertThat (new Response (503 ), isServerError ());
215
215
}
216
216
217
217
public function testIsServerErrorCanFail ()
218
218
{
219
219
$ this ->expectException (AssertionFailedError::class);
220
220
221
- assertThat (new Response (200 ), isServerError ());
221
+ self :: assertThat (new Response (200 ), isServerError ());
222
222
}
223
223
224
224
public function testHasContentTypeSucceedsOnEquality ()
225
225
{
226
- assertThat (new Response (200 , ['content-type ' => ['application/json ' ]]), hasContentType ('application/json ' ));
226
+ self :: assertThat (new Response (200 , ['content-type ' => ['application/json ' ]]), hasContentType ('application/json ' ));
227
227
}
228
228
229
229
public function testHasContentTypeSucceedsWithCharset ()
230
230
{
231
- assertThat (new Response (200 , ['content-type ' => ['application/json;charset=utf8 ' ]]), hasContentType ('application/json ' ));
231
+ self :: assertThat (new Response (200 , ['content-type ' => ['application/json;charset=utf8 ' ]]), hasContentType ('application/json ' ));
232
232
}
233
233
234
234
}
0 commit comments