From 08f88c1f167f51fde735bdddf503738f0c3c3df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Mon, 24 Nov 2025 12:10:37 +0100 Subject: [PATCH 1/2] Add support for Symfony 8 --- .github/workflows/test-application.yaml | 12 +++++++++++- composer.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index be830dd..bf0300c 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -19,11 +19,17 @@ jobs: include: - php-version: '8.0' dependencies: 'lowest' + symfony-version: '*' - php-version: '8.1' + symfony-version: '7.*' - php-version: '8.2' + symfony-version: '7.*' - php-version: '8.3' + symfony-version: '7.*' - php-version: '8.4' + symfony-version: '8.*' - php-version: '8.5' + symfony-version: '8.*' steps: - name: Checkout project @@ -33,7 +39,11 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - tools: 'composer:v2' + tools: 'composer:v2, flex' + + - name: Symfony version + if: matrix.symfony-version != '*' + run: composer config extra.symfony.require ${{ matrix.symfony-version }} - name: Allow unstable dependencies if: matrix.dev-dependencies == true diff --git a/composer.json b/composer.json index 9889173..93d7fec 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "require": { "php": "^8.0", "phpcr/phpcr": "~2.1.0", - "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0" }, "require-dev": { "ramsey/uuid": "^3.5", From 7da1c5011e9df65e991eceae7b5e09cbf82158a4 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 29 Nov 2025 13:15:30 +0100 Subject: [PATCH 2/2] adjust how we add commands to application in tests for symfony 8 --- .github/workflows/test-application.yaml | 2 +- CHANGELOG.md | 6 ++++++ .../Util/Console/Command/BaseCommandTest.php | 17 +++++++++++++++++ .../Console/Command/NodeDumpCommandTest.php | 2 +- .../Console/Command/NodeMoveCommandTest.php | 2 +- .../Console/Command/NodeRemoveCommandTest.php | 2 +- .../Console/Command/NodeTouchCommandTest.php | 2 +- .../Console/Command/NodeTypeListCommandTest.php | 2 +- .../Command/NodeTypeRegisterCommandTest.php | 2 +- .../Console/Command/NodesUpdateCommandTest.php | 2 +- .../Command/WorkspaceCreateCommandTest.php | 2 +- .../Command/WorkspaceDeleteCommandTest.php | 2 +- .../Command/WorkspaceExportCommandTest.php | 2 +- .../Command/WorkspaceImportCommandTest.php | 2 +- .../Command/WorkspaceListCommandTest.php | 2 +- .../Command/WorkspacePurgeCommandTest.php | 2 +- .../Command/WorkspaceQueryCommandTest.php | 2 +- 17 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index bf0300c..af33f9c 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -21,7 +21,7 @@ jobs: dependencies: 'lowest' symfony-version: '*' - php-version: '8.1' - symfony-version: '7.*' + symfony-version: '6.*' - php-version: '8.2' symfony-version: '7.*' - php-version: '8.3' diff --git a/CHANGELOG.md b/CHANGELOG.md index c560bbc..93f0b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Changelog 2.x --- +2.0.3 +----- + +* Allow installation with Symfony Console 8.x. +* Test with PHP 8.5. + 2.0.2 ----- diff --git a/tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php index a0300ce..b576c27 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Tester\CommandTester; @@ -110,6 +111,22 @@ public function setUp(): void $this->application->setHelperSet($this->helperSet); } + protected function addCommand(callable|Command $command): void + { + /* @phpstan-ignore function.alreadyNarrowedType */ + if (method_exists($this->application, 'addCommand')) { + $this->application->addCommand($command); + + return; + } + + if (!$command instanceof Command) { + throw new \InvalidArgumentException('Until we remove support for symfony console < 7.4, all commands must extend the base class'); + } + + $this->application->add($command); + } + /** * Build and execute the command tester. * diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php index 5e5da9a..799f95f 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php @@ -23,7 +23,7 @@ public function setUp(): void ->getMock(); $ndCommand = new NodeDumpCommand(); - $this->application->add($ndCommand); + $this->addCommand($ndCommand); } public function testCommand(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeMoveCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeMoveCommandTest.php index 4dee112..3677f99 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeMoveCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeMoveCommandTest.php @@ -37,7 +37,7 @@ public function testCommand(array $args): void $this->session->expects($this->once()) ->method('save'); - $this->application->add(new NodeMoveCommand()); + $this->addCommand(new NodeMoveCommand()); $this->executeCommand('phpcr:node:move', $args); } } diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php index 6381ba5..917ebbf 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php @@ -12,7 +12,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new NodeRemoveCommand()); + $this->addCommand(new NodeRemoveCommand()); } public function testRemove(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php index afc746d..5efe0e5 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php @@ -26,7 +26,7 @@ public function setUp(): void parent::setUp(); $command = new NodeTouchCommand(); - $this->application->add($command); + $this->addCommand($command); // Override default concrete instance with mock $this->phpcrHelper = $this->getMockBuilder(PhpcrHelper::class) diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php index fb25baf..d8ef197 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php @@ -19,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new NodeTypeListCommand()); + $this->addCommand(new NodeTypeListCommand()); $this->nodeTypeManager = $this->getMockBuilder(MockNodeTypeManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodeTypeRegisterCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodeTypeRegisterCommandTest.php index 712b4a1..a51a646 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodeTypeRegisterCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodeTypeRegisterCommandTest.php @@ -19,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new NodeTypeRegisterCommand()); + $this->addCommand(new NodeTypeRegisterCommand()); $this->nodeTypeManager = $this->getMockBuilder(MockNodeTypeManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/PHPCR/Tests/Util/Console/Command/NodesUpdateCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/NodesUpdateCommandTest.php index 6806109..5dc128c 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/NodesUpdateCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/NodesUpdateCommandTest.php @@ -19,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new NodesUpdateCommand()); + $this->addCommand(new NodesUpdateCommand()); $this->query = $this->createMock(QueryInterface::class); } diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceCreateCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceCreateCommandTest.php index f3352a3..9125ee3 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceCreateCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceCreateCommandTest.php @@ -13,7 +13,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceCreateCommand()); + $this->addCommand(new WorkspaceCreateCommand()); } public function testCreate(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceDeleteCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceDeleteCommandTest.php index 30df140..50e7e30 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceDeleteCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceDeleteCommandTest.php @@ -13,7 +13,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceDeleteCommand()); + $this->addCommand(new WorkspaceDeleteCommand()); } public function testDelete(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php index 95ea9f2..5f9ee89 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php @@ -13,7 +13,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceExportCommand()); + $this->addCommand(new WorkspaceExportCommand()); } public function tearDown(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceImportCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceImportCommandTest.php index 13e16cf..af48984 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceImportCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceImportCommandTest.php @@ -14,7 +14,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceImportCommand()); + $this->addCommand(new WorkspaceImportCommand()); } public function testImport(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceListCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceListCommandTest.php index 1044200..7ee1777 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceListCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceListCommandTest.php @@ -12,7 +12,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceListCommand()); + $this->addCommand(new WorkspaceListCommand()); } public function testNodeTypeList(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspacePurgeCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspacePurgeCommandTest.php index f37ecfe..5f83b43 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspacePurgeCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspacePurgeCommandTest.php @@ -12,7 +12,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspacePurgeCommand()); + $this->addCommand(new WorkspacePurgeCommand()); } public function testNodeTypePurge(): void diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceQueryCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceQueryCommandTest.php index d751012..458465a 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceQueryCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceQueryCommandTest.php @@ -19,7 +19,7 @@ public function setUp(): void { parent::setUp(); - $this->application->add(new WorkspaceQueryCommand()); + $this->addCommand(new WorkspaceQueryCommand()); $this->query = $this->createMock(QueryInterface::class); }