Skip to content

Commit 9825920

Browse files
authored
Merge pull request #446 from Art4/phpunit-12
Run tests with PHPUnit 12
2 parents 8626fa7 + 669b0b7 commit 9825920

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"behat/behat": "^3.14",
3434
"friendsofphp/php-cs-fixer": "^3.68",
3535
"guzzlehttp/psr7": "^2",
36-
"php-mock/php-mock-phpunit": "^2.6",
36+
"php-mock/php-mock-phpunit": "^2.13",
3737
"phpstan/phpstan": "^2.1",
38-
"phpunit/phpunit": "^9.5 || ^10.5"
38+
"phpunit/phpunit": "^9.5 || ^10.5 || ^11.2 || ^12.0.9"
3939
},
4040
"autoload": {
4141
"psr-4": {

tests/Behat/Bootstrap/FeatureContext.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use RuntimeException;
2121
use SimpleXMLElement;
2222

23-
final class FeatureContext extends TestCase implements Context
23+
final class FeatureContext implements Context
2424
{
2525
use AttachmentContextTrait;
2626
use CustomFieldContextTrait;
@@ -90,8 +90,6 @@ public function __construct(string $redmineVersion, string $rootPath)
9090
}
9191

9292
$this->redmine = static::$tracer::getRedmineInstance($version, $rootPath);
93-
94-
parent::__construct('BehatRedmine' . $version->asId());
9593
}
9694

9795
/**
@@ -126,7 +124,7 @@ private function registerClientResponse(mixed $lastReturn, Response $lastRespons
126124
*/
127125
public function theResponseHasTheStatusCode(int $statusCode)
128126
{
129-
$this->assertSame(
127+
TestCase::assertSame(
130128
$statusCode,
131129
$this->lastResponse->getStatusCode(),
132130
'Raw response content: ' . $this->lastResponse->getContent(),
@@ -138,7 +136,7 @@ public function theResponseHasTheStatusCode(int $statusCode)
138136
*/
139137
public function theResponseHasTheContentType(string $contentType)
140138
{
141-
$this->assertStringStartsWith(
139+
TestCase::assertStringStartsWith(
142140
$contentType,
143141
$this->lastResponse->getContentType(),
144142
'Raw response content: ' . $this->lastResponse->getContent(),
@@ -150,79 +148,79 @@ public function theResponseHasTheContentType(string $contentType)
150148
*/
151149
public function theResponseHasAnEmptyContentType()
152150
{
153-
$this->assertSame('', $this->lastResponse->getContentType());
151+
TestCase::assertSame('', $this->lastResponse->getContentType());
154152
}
155153

156154
/**
157155
* @Then the response has the content :content
158156
*/
159157
public function theResponseHasTheContent(string $content)
160158
{
161-
$this->assertSame($content, $this->lastResponse->getContent());
159+
TestCase::assertSame($content, $this->lastResponse->getContent());
162160
}
163161

164162
/**
165163
* @Then the response has the content
166164
*/
167165
public function theResponseHasTheContentWithMultipleLines(PyStringNode $string)
168166
{
169-
$this->assertSame($string->getRaw(), $this->lastResponse->getContent());
167+
TestCase::assertSame($string->getRaw(), $this->lastResponse->getContent());
170168
}
171169

172170
/**
173171
* @Then the returned data is true
174172
*/
175173
public function theReturnedDataIsTrue()
176174
{
177-
$this->assertTrue($this->lastReturn);
175+
TestCase::assertTrue($this->lastReturn);
178176
}
179177

180178
/**
181179
* @Then the returned data is false
182180
*/
183181
public function theReturnedDataIsFalse()
184182
{
185-
$this->assertFalse($this->lastReturn);
183+
TestCase::assertFalse($this->lastReturn);
186184
}
187185

188186
/**
189187
* @Then the returned data is exactly :content
190188
*/
191189
public function theReturnedDataIsExactly(string $content)
192190
{
193-
$this->assertSame($content, $this->lastReturn);
191+
TestCase::assertSame($content, $this->lastReturn);
194192
}
195193

196194
/**
197195
* @Then the returned data is exactly
198196
*/
199197
public function theReturnedDataIsExactlyWithMultipleLines(PyStringNode $string)
200198
{
201-
$this->assertSame($string->getRaw(), $this->lastReturn);
199+
TestCase::assertSame($string->getRaw(), $this->lastReturn);
202200
}
203201

204202
/**
205203
* @Then the returned data is an instance of :className
206204
*/
207205
public function theReturnedDataIsAnInstanceOf(string $className)
208206
{
209-
$this->assertInstanceOf($className, $this->lastReturn);
207+
TestCase::assertInstanceOf($className, $this->lastReturn);
210208
}
211209

212210
/**
213211
* @Then the returned data is an array
214212
*/
215213
public function theReturnedDataIsAnArray()
216214
{
217-
$this->assertIsArray($this->lastReturn);
215+
TestCase::assertIsArray($this->lastReturn);
218216
}
219217

220218
/**
221219
* @Then the returned data contains :count items
222220
*/
223221
public function theReturnedDataContainsItems(int $count)
224222
{
225-
$this->assertCount($count, $this->lastReturn);
223+
TestCase::assertCount($count, $this->lastReturn);
226224
}
227225

228226
/**
@@ -264,7 +262,7 @@ public function theReturnedDataPropertyIsAnArray($property)
264262

265263
$value = $this->getItemFromArray($returnData, $property);
266264

267-
$this->assertIsArray($value);
265+
TestCase::assertIsArray($value);
268266
}
269267

270268
/**
@@ -276,8 +274,8 @@ public function theReturnedDataPropertyContainsItems($property, int $count)
276274

277275
$value = $this->getItemFromArray($returnData, $property);
278276

279-
$this->assertIsArray($value);
280-
$this->assertCount($count, $value);
277+
TestCase::assertIsArray($value);
278+
TestCase::assertCount($count, $value);
281279
}
282280

283281
/**
@@ -321,7 +319,7 @@ public function theReturnedDataPropertyHasOnlyTheFollowingProperties($property,
321319

322320
$properties = array_keys($value);
323321

324-
$this->assertSame($string->getStrings(), $properties);
322+
TestCase::assertSame($string->getStrings(), $properties);
325323
}
326324

327325
/**
@@ -393,7 +391,7 @@ private function getItemFromArray(array $array, $key): mixed
393391
private function assertTableNodeIsSameAsArray(TableNode $table, array $data)
394392
{
395393
foreach ($table as $row) {
396-
$this->assertArrayHasKey($row['property'], $data, 'Possible keys are: ' . implode(', ', array_keys($data)));
394+
TestCase::assertArrayHasKey($row['property'], $data, 'Possible keys are: ' . implode(', ', array_keys($data)));
397395

398396
$value = $data[$row['property']];
399397

@@ -438,7 +436,7 @@ private function assertTableNodeIsSameAsArray(TableNode $table, array $data)
438436
$expected = str_replace('%redmine_id%', strval($this->redmine->getVersionId()), $expected);
439437
}
440438

441-
$this->assertSame($expected, $value, 'Error with property "' . $row['property'] . '"');
439+
TestCase::assertSame($expected, $value, 'Error with property "' . $row['property'] . '"');
442440
}
443441
}
444442
}

0 commit comments

Comments
 (0)