Skip to content

Commit 8cbab18

Browse files
Make tests pass with PHPUnit 8 AND 9
1 parent 3af135f commit 8cbab18

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"autoload-dev": {
2929
"files": [
30-
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php",
3130
"vendor/helmich/phpunit-json-assert/src/Functions.php",
3231
"src/Functions.php"
3332
]

tests/Functional/FunctionalConstraintTest.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,49 @@ class FunctionalConstraintTest extends TestCase
1414
public function testHasUriCanSucceed()
1515
{
1616
$request = new Request('GET', '/foo');
17-
assertThat($request, hasUri('/foo'));
17+
self::assertThat($request, hasUri('/foo'));
1818
}
1919

2020
public function testHasUriCanFail()
2121
{
2222
$this->expectException(AssertionFailedError::class);
2323

2424
$request = new Request('GET', '/foo');
25-
assertThat($request, hasUri('/bar'));
25+
self::assertThat($request, hasUri('/bar'));
2626
}
2727

2828
public function testHasHeaderCanSucceedWithPrimitiveValue()
2929
{
3030
$request = new Request('GET', '/', ['x-foo' => 'bar']);
31-
assertThat($request, hasHeader('X-Foo', 'bar'));
31+
self::assertThat($request, hasHeader('X-Foo', 'bar'));
3232
}
3333

3434
public function testHasHeaderCanFailWithPrimitiveValue()
3535
{
3636
$this->expectException(AssertionFailedError::class);
3737

3838
$request = new Request('GET', '/', ['x-foo' => 'baz']);
39-
assertThat($request, hasHeader('X-Foo', 'bar'));
39+
self::assertThat($request, hasHeader('X-Foo', 'bar'));
4040
}
4141

4242
public function testHasHeaderCanFailWithNonExistingHeader()
4343
{
4444
$this->expectException(AssertionFailedError::class);
4545

4646
$request = new Request('GET', '/', []);
47-
assertThat($request, hasHeader('X-Foo', 'bar'));
47+
self::assertThat($request, hasHeader('X-Foo', 'bar'));
4848
}
4949

5050
public function testHasHeaderCanSucceedWithConstraint()
5151
{
5252
$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)));
5454
}
5555

5656
public function testHasHeadersCanSucceedWithConstraint()
5757
{
5858
$request = new Request('GET', '/', ['x-foo' => 14, 'content-type' => 'text/plain']);
59-
assertThat($request, hasHeaders([
59+
self::assertThat($request, hasHeaders([
6060
'X-Foo' => Assert::greaterThanOrEqual(10),
6161
'Content-Type' => 'text/plain',
6262
]));
@@ -67,27 +67,27 @@ public function testHasHeaderCanFailWithConstraint()
6767
$this->expectException(AssertionFailedError::class);
6868

6969
$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)));
7171
}
7272

7373
public function testBodyMatchesCanSucceed()
7474
{
7575
$request = new Request('GET', '/', [], 'foobar');
76-
assertThat($request, bodyMatches(equalTo('foobar')));
76+
self::assertThat($request, bodyMatches(self::equalTo('foobar')));
7777
}
7878

7979
public function testBodyMatchesCanFail()
8080
{
8181
$this->expectException(AssertionFailedError::class);
8282

8383
$request = new Request('GET', '/', [], 'foobar');
84-
assertThat($request, bodyMatches(equalTo('barbaz')));
84+
self::assertThat($request, bodyMatches(self::equalTo('barbaz')));
8585
}
8686

8787
public function testBodyMatchesJsonCanSucceed()
8888
{
8989
$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']));
9191
}
9292

9393
public function dataForRequestMethods()
@@ -109,55 +109,55 @@ public function dataForRequestMethods()
109109
*/
110110
public function testAssertRequestHasMethodCanSucceed($method)
111111
{
112-
assertThat(new Request($method, '/'), hasMethod($method));
112+
self::assertThat(new Request($method, '/'), hasMethod($method));
113113
}
114114

115115
public function testIsGetCanSucceed()
116116
{
117-
assertThat(new Request('GET', '/'), isGet());
117+
self::assertThat(new Request('GET', '/'), isGet());
118118
}
119119

120120
public function testIsGetCanFail()
121121
{
122122
$this->expectException(AssertionFailedError::class);
123123

124-
assertThat(new Request('POST', '/'), isGet());
124+
self::assertThat(new Request('POST', '/'), isGet());
125125
}
126126

127127
public function testIsPostCanSucceed()
128128
{
129-
assertThat(new Request('POST', '/'), isPost());
129+
self::assertThat(new Request('POST', '/'), isPost());
130130
}
131131

132132
public function testIsPostCanFail()
133133
{
134134
$this->expectException(AssertionFailedError::class);
135135

136-
assertThat(new Request('GET', '/'), isPost());
136+
self::assertThat(new Request('GET', '/'), isPost());
137137
}
138138

139139
public function testIsPutCanSucceed()
140140
{
141-
assertThat(new Request('PUT', '/'), isPut());
141+
self::assertThat(new Request('PUT', '/'), isPut());
142142
}
143143

144144
public function testIsPutCanFail()
145145
{
146146
$this->expectException(AssertionFailedError::class);
147147

148-
assertThat(new Request('GET', '/'), isPut());
148+
self::assertThat(new Request('GET', '/'), isPut());
149149
}
150150

151151
public function testIsDeleteCanSucceed()
152152
{
153-
assertThat(new Request('DELETE', '/'), isDelete());
153+
self::assertThat(new Request('DELETE', '/'), isDelete());
154154
}
155155

156156
public function testIsDeleteCanFail()
157157
{
158158
$this->expectException(AssertionFailedError::class);
159159

160-
assertThat(new Request('POST', '/'), isDelete());
160+
self::assertThat(new Request('POST', '/'), isDelete());
161161
}
162162

163163
public function dataForStatusCodes()
@@ -175,60 +175,60 @@ public function dataForStatusCodes()
175175
*/
176176
public function testHasStatusCanSucceed($status)
177177
{
178-
assertThat(new Response($status), hasStatus($status));
178+
self::assertThat(new Response($status), hasStatus($status));
179179
}
180180

181181
public function testHasStatusCanFail()
182182
{
183183
$this->expectException(AssertionFailedError::class);
184184

185-
assertThat(new Response(400), hasStatus(200));
185+
self::assertThat(new Response(400), hasStatus(200));
186186
}
187187

188188
public function testIsSuccessCanSucceed()
189189
{
190-
assertThat(new Response(200), isSuccess());
190+
self::assertThat(new Response(200), isSuccess());
191191
}
192192

193193
public function testIsSuccessCanFail()
194194
{
195195
$this->expectException(AssertionFailedError::class);
196196

197-
assertThat(new Response(404), isSuccess());
197+
self::assertThat(new Response(404), isSuccess());
198198
}
199199

200200
public function testIsClientErrorCanSucceed()
201201
{
202-
assertThat(new Response(404), isClientError());
202+
self::assertThat(new Response(404), isClientError());
203203
}
204204

205205
public function testIsClientErrorCanFail()
206206
{
207207
$this->expectException(AssertionFailedError::class);
208208

209-
assertThat(new Response(200), isClientError());
209+
self::assertThat(new Response(200), isClientError());
210210
}
211211

212212
public function testIsServerErrorCanSucceed()
213213
{
214-
assertThat(new Response(503), isServerError());
214+
self::assertThat(new Response(503), isServerError());
215215
}
216216

217217
public function testIsServerErrorCanFail()
218218
{
219219
$this->expectException(AssertionFailedError::class);
220220

221-
assertThat(new Response(200), isServerError());
221+
self::assertThat(new Response(200), isServerError());
222222
}
223223

224224
public function testHasContentTypeSucceedsOnEquality()
225225
{
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'));
227227
}
228228

229229
public function testHasContentTypeSucceedsWithCharset()
230230
{
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'));
232232
}
233233

234234
}

tests/Unit/Constraint/HasQueryParameterConstraintTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,31 @@ public function testMatchesStringUrls()
1414
$url = "https://some-domain.example/foo?bar=baz";
1515
$constraint = new HasQueryParameterConstraint("bar", "baz");
1616

17-
assertThat($constraint->evaluate($url, "", true), isTrue());
17+
self::assertThat($constraint->evaluate($url, "", true), self::isTrue());
1818
}
1919

2020
public function testMatchesStringUrlsNegative()
2121
{
2222
$url = "https://some-domain.example/foo?bar=baz";
2323
$constraint = new HasQueryParameterConstraint("tulpen", "bunt");
2424

25-
assertThat($constraint->evaluate($url, "", true), isFalse());
25+
self::assertThat($constraint->evaluate($url, "", true), self::isFalse());
2626
}
2727

2828
public function testMatchesPsr7Uris()
2929
{
3030
$uri = uri_for("https://some-domain.example/foo?bar=baz");
3131
$constraint = new HasQueryParameterConstraint("bar", "baz");
3232

33-
assertThat($constraint->evaluate($uri, "", true), isTrue());
33+
self::assertThat($constraint->evaluate($uri, "", true), self::isTrue());
3434
}
3535

3636
public function testMatchesPsr7UrisNegative()
3737
{
3838
$uri = uri_for("https://some-domain.example/foo?autobahn=1");
3939
$constraint = new HasQueryParameterConstraint("bar", "baz");
4040

41-
assertThat($constraint->evaluate($uri, "", true), isFalse());
41+
self::assertThat($constraint->evaluate($uri, "", true), self::isFalse());
4242
}
4343

4444
public function testMatchesRequest()
@@ -48,6 +48,6 @@ public function testMatchesRequest()
4848

4949
$constraint = new HasQueryParameterConstraint("bar", "baz");
5050

51-
assertThat($constraint->evaluate($request, "", true), isTrue());
51+
self::assertThat($constraint->evaluate($request, "", true), self::isTrue());
5252
}
5353
}

tests/Unit/Constraint/HasQueryParametersConstraintTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testMatchesStringUrls()
1515
"baz" => "bar"
1616
]);
1717

18-
assertThat($constraint->evaluate($url, "", true), isTrue());
18+
self::assertThat($constraint->evaluate($url, "", true), self::isTrue());
1919
}
2020

2121
public function testMatchesStringUrlsNegative()
@@ -26,6 +26,6 @@ public function testMatchesStringUrlsNegative()
2626
"baz" => "bar"
2727
]);
2828

29-
assertThat($constraint->evaluate($url, "", true), isFalse());
29+
self::assertThat($constraint->evaluate($url, "", true), self::isFalse());
3030
}
3131
}

tests/Unit/Constraint/IsAbsoluteUriConstraintTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function invalidUrls(): array {
3535
public function testValidUrlMatches($validUrl)
3636
{
3737
$constraint = new IsAbsoluteUriConstraint();
38-
assertThat($constraint->evaluate($validUrl, "", true), isTrue());
38+
self::assertThat($constraint->evaluate($validUrl, "", true), self::isTrue());
3939
}
4040

4141
/**
@@ -45,6 +45,6 @@ public function testValidUrlMatches($validUrl)
4545
public function testInvalidUrlDoesNotMatch($invalidUrl)
4646
{
4747
$constraint = new IsAbsoluteUriConstraint();
48-
assertThat($constraint->evaluate($invalidUrl, "", true), isFalse());
48+
self::assertThat($constraint->evaluate($invalidUrl, "", true), self::isFalse());
4949
}
5050
}

0 commit comments

Comments
 (0)