Skip to content

Commit

Permalink
Upgrade PHPUnit to v10 (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Aug 8, 2024
1 parent ffe33bc commit c2f865f
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 300 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"phpstan/phpstan": "^1.11.5",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-strict-rules": "^1.6.0",
"phpunit/phpunit": "^9.5.28",
"phpunit/phpunit": "^10.5.29",
"psr/log": "^1 || ^2 || ^3",
"shipmonk/composer-dependency-analyser": "^1.0",
"shipmonk/phpstan-rules": "^3.0.0",
Expand Down Expand Up @@ -57,7 +57,7 @@
"composer-dependency-analyser"
],
"check:ec": "ec src",
"check:tests": "phpunit -vvv tests",
"check:tests": "phpunit tests",
"check:types": "phpstan analyse -vvv",
"fix:cs": "phpcbf"
}
Expand Down
519 changes: 236 additions & 283 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutCoverageMetadata="true"
failOnRisky="true"
failOnWarning="true"
cacheResultFile="cache/phpunit.result.cache"
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/MigrationCheckCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use PHPUnit\Framework\TestCase;
use ShipMonk\Doctrine\Migration\MigrationService;
use ShipMonk\Doctrine\Migration\WithEntityManagerTest;
use ShipMonk\Doctrine\Migration\WithEntityManagerTestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use const PHP_EOL;

class MigrationCheckCommandTest extends TestCase
{

use WithEntityManagerTest;
use WithEntityManagerTestCase;

public function testCheck(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/MigrationGenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
use PHPUnit\Framework\TestCase;
use ShipMonk\Doctrine\Migration\MigrationFile;
use ShipMonk\Doctrine\Migration\MigrationService;
use ShipMonk\Doctrine\Migration\WithEntityManagerTest;
use ShipMonk\Doctrine\Migration\WithEntityManagerTestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use const PHP_EOL;

class MigrationGenerateCommandTest extends TestCase
{

use WithEntityManagerTest;
use WithEntityManagerTestCase;

public function testCheck(): void
{
Expand Down
20 changes: 13 additions & 7 deletions tests/Command/MigrationRunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ public function testRunBoth(): void
->method('getPreparedVersions')
->willReturn(['version1' => 'version1', 'version2' => 'version2']);

$migrationService->expects(self::exactly(4))
$executeCallsMatcher = self::exactly(4);
$migrationService->expects($executeCallsMatcher)
->method('executeMigration')
->withConsecutive(
['version1', MigrationPhase::BEFORE],
['version1', MigrationPhase::AFTER],
['version2', MigrationPhase::BEFORE],
['version2', MigrationPhase::AFTER],
);
->willReturnCallback(function (string $version, string $phase) use ($executeCallsMatcher): MigrationRun {
match ($executeCallsMatcher->numberOfInvocations()) {
1 => self::assertEquals(['version1', MigrationPhase::BEFORE], [$version, $phase]),
2 => self::assertEquals(['version1', MigrationPhase::AFTER], [$version, $phase]),
3 => self::assertEquals(['version2', MigrationPhase::BEFORE], [$version, $phase]),
4 => self::assertEquals(['version2', MigrationPhase::AFTER], [$version, $phase]),
default => self::fail('Unexpected call'),
};

return $this->createMock(MigrationRun::class);
});

$command = new MigrationRunCommand($migrationService);

Expand Down
2 changes: 1 addition & 1 deletion tests/MigrationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class MigrationServiceTest extends TestCase
{

use WithEntityManagerTest;
use WithEntityManagerTestCase;

public function testInitGenerationExecution(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function is_file;
use function unlink;

trait WithEntityManagerTest
trait WithEntityManagerTestCase
{

/**
Expand Down

0 comments on commit c2f865f

Please sign in to comment.