Skip to content

Commit

Permalink
Upgrade to PHPUnit 11 (#1885)
Browse files Browse the repository at this point in the history
Address deprecation warnings:

> Targeting a trait such as Smr\Container\ResettableContainerTrait with #[CoversClass] is deprecated, please refactor your test to use #[CoversTrait] instead.

> returnValueMap() is deprecated and will be removed in PHPUnit 12. Use $double->willReturnMap() instead of $double->will($this->returnValueMap())
  • Loading branch information
hemberger authored Jul 28, 2024
1 parent a5fb56d commit 67f8872
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"fig-r/psr2r-sniffer": "2.1.0",
"overtrue/phplint": "9.3.1",
"phpstan/phpstan": "1.11.8",
"phpunit/phpunit": "10.5.24",
"phpunit/php-code-coverage": "10.1.14",
"phpunit/phpunit": "11.2.6",
"phpunit/php-code-coverage": "11.0.5",
"rector/rector": "0.15.13",
"squizlabs/php_codesniffer": "3.10.1"
}
Expand Down
4 changes: 2 additions & 2 deletions test/SmrTest/Container/ResettableContainerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace SmrTest\Container;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversTrait;
use PHPUnit\Framework\TestCase;
use Smr\Container\ResettableContainer;
use Smr\Container\ResettableContainerTrait;

#[CoversClass(ResettableContainerTrait::class)]
#[CoversTrait(ResettableContainerTrait::class)]
class ResettableContainerTraitTest extends TestCase {

public function test_not_initialized_by_definition(): void {
Expand Down
2 changes: 1 addition & 1 deletion test/SmrTest/lib/Routes/RouteGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private function createPortStub(int $raceID, array $goods): Port {
foreach ($goods as $goodID => [$_, $distance]) {
$getGoodDistanceMap[] = [$goodID, $distance];
}
$port->method('getGoodDistance')->will(self::returnValueMap($getGoodDistanceMap));
$port->method('getGoodDistance')->willReturnMap($getGoodDistanceMap);

// We could call `setRaceID` instead, but `raceID` is not initialized
$port->method('getRaceID')->willReturn($raceID);
Expand Down

0 comments on commit 67f8872

Please sign in to comment.