Skip to content

Run tests with PHPUnit 12 #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"behat/behat": "^3.14",
"friendsofphp/php-cs-fixer": "^3.68",
"guzzlehttp/psr7": "^2",
"php-mock/php-mock-phpunit": "^2.6",
"php-mock/php-mock-phpunit": "^2.13",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^9.5 || ^10.5"
"phpunit/phpunit": "^9.5 || ^10.5 || ^11.2 || ^12.0.9"
},
"autoload": {
"psr-4": {
Expand Down
40 changes: 19 additions & 21 deletions tests/Behat/Bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use RuntimeException;
use SimpleXMLElement;

final class FeatureContext extends TestCase implements Context
final class FeatureContext implements Context
{
use AttachmentContextTrait;
use CustomFieldContextTrait;
Expand Down Expand Up @@ -90,8 +90,6 @@ public function __construct(string $redmineVersion, string $rootPath)
}

$this->redmine = static::$tracer::getRedmineInstance($version, $rootPath);

parent::__construct('BehatRedmine' . $version->asId());
}

/**
Expand Down Expand Up @@ -126,7 +124,7 @@ private function registerClientResponse(mixed $lastReturn, Response $lastRespons
*/
public function theResponseHasTheStatusCode(int $statusCode)
{
$this->assertSame(
TestCase::assertSame(
$statusCode,
$this->lastResponse->getStatusCode(),
'Raw response content: ' . $this->lastResponse->getContent(),
Expand All @@ -138,7 +136,7 @@ public function theResponseHasTheStatusCode(int $statusCode)
*/
public function theResponseHasTheContentType(string $contentType)
{
$this->assertStringStartsWith(
TestCase::assertStringStartsWith(
$contentType,
$this->lastResponse->getContentType(),
'Raw response content: ' . $this->lastResponse->getContent(),
Expand All @@ -150,79 +148,79 @@ public function theResponseHasTheContentType(string $contentType)
*/
public function theResponseHasAnEmptyContentType()
{
$this->assertSame('', $this->lastResponse->getContentType());
TestCase::assertSame('', $this->lastResponse->getContentType());
}

/**
* @Then the response has the content :content
*/
public function theResponseHasTheContent(string $content)
{
$this->assertSame($content, $this->lastResponse->getContent());
TestCase::assertSame($content, $this->lastResponse->getContent());
}

/**
* @Then the response has the content
*/
public function theResponseHasTheContentWithMultipleLines(PyStringNode $string)
{
$this->assertSame($string->getRaw(), $this->lastResponse->getContent());
TestCase::assertSame($string->getRaw(), $this->lastResponse->getContent());
}

/**
* @Then the returned data is true
*/
public function theReturnedDataIsTrue()
{
$this->assertTrue($this->lastReturn);
TestCase::assertTrue($this->lastReturn);
}

/**
* @Then the returned data is false
*/
public function theReturnedDataIsFalse()
{
$this->assertFalse($this->lastReturn);
TestCase::assertFalse($this->lastReturn);
}

/**
* @Then the returned data is exactly :content
*/
public function theReturnedDataIsExactly(string $content)
{
$this->assertSame($content, $this->lastReturn);
TestCase::assertSame($content, $this->lastReturn);
}

/**
* @Then the returned data is exactly
*/
public function theReturnedDataIsExactlyWithMultipleLines(PyStringNode $string)
{
$this->assertSame($string->getRaw(), $this->lastReturn);
TestCase::assertSame($string->getRaw(), $this->lastReturn);
}

/**
* @Then the returned data is an instance of :className
*/
public function theReturnedDataIsAnInstanceOf(string $className)
{
$this->assertInstanceOf($className, $this->lastReturn);
TestCase::assertInstanceOf($className, $this->lastReturn);
}

/**
* @Then the returned data is an array
*/
public function theReturnedDataIsAnArray()
{
$this->assertIsArray($this->lastReturn);
TestCase::assertIsArray($this->lastReturn);
}

/**
* @Then the returned data contains :count items
*/
public function theReturnedDataContainsItems(int $count)
{
$this->assertCount($count, $this->lastReturn);
TestCase::assertCount($count, $this->lastReturn);
}

/**
Expand Down Expand Up @@ -264,7 +262,7 @@ public function theReturnedDataPropertyIsAnArray($property)

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

$this->assertIsArray($value);
TestCase::assertIsArray($value);
}

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

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

$this->assertIsArray($value);
$this->assertCount($count, $value);
TestCase::assertIsArray($value);
TestCase::assertCount($count, $value);
}

/**
Expand Down Expand Up @@ -321,7 +319,7 @@ public function theReturnedDataPropertyHasOnlyTheFollowingProperties($property,

$properties = array_keys($value);

$this->assertSame($string->getStrings(), $properties);
TestCase::assertSame($string->getStrings(), $properties);
}

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

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

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

$this->assertSame($expected, $value, 'Error with property "' . $row['property'] . '"');
TestCase::assertSame($expected, $value, 'Error with property "' . $row['property'] . '"');
}
}
}