Skip to content

Commit c0ad706

Browse files
authored
Merge pull request #229 from phpcr/sf8
Add support for Symfony 8 (cont)
2 parents 95728ed + 7da1c50 commit c0ad706

18 files changed

+49
-16
lines changed

.github/workflows/test-application.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ jobs:
1919
include:
2020
- php-version: '8.0'
2121
dependencies: 'lowest'
22+
symfony-version: '*'
2223
- php-version: '8.1'
24+
symfony-version: '6.*'
2325
- php-version: '8.2'
26+
symfony-version: '7.*'
2427
- php-version: '8.3'
28+
symfony-version: '7.*'
2529
- php-version: '8.4'
30+
symfony-version: '8.*'
2631
- php-version: '8.5'
32+
symfony-version: '8.*'
2733

2834
steps:
2935
- name: Checkout project
@@ -33,7 +39,11 @@ jobs:
3339
uses: shivammathur/setup-php@v2
3440
with:
3541
php-version: ${{ matrix.php-version }}
36-
tools: 'composer:v2'
42+
tools: 'composer:v2, flex'
43+
44+
- name: Symfony version
45+
if: matrix.symfony-version != '*'
46+
run: composer config extra.symfony.require ${{ matrix.symfony-version }}
3747

3848
- name: Allow unstable dependencies
3949
if: matrix.dev-dependencies == true

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Changelog
44
2.x
55
---
66

7+
2.0.3
8+
-----
9+
10+
* Allow installation with Symfony Console 8.x.
11+
* Test with PHP 8.5.
12+
713
2.0.2
814
-----
915

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"require": {
3030
"php": "^8.0",
3131
"phpcr/phpcr": "~2.1.0",
32-
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
32+
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0"
3333
},
3434
"require-dev": {
3535
"ramsey/uuid": "^3.5",

tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PHPUnit\Framework\MockObject\MockObject;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Component\Console\Application;
20+
use Symfony\Component\Console\Command\Command;
2021
use Symfony\Component\Console\Helper\HelperSet;
2122
use Symfony\Component\Console\Tester\CommandTester;
2223

@@ -110,6 +111,22 @@ public function setUp(): void
110111
$this->application->setHelperSet($this->helperSet);
111112
}
112113

114+
protected function addCommand(callable|Command $command): void
115+
{
116+
/* @phpstan-ignore function.alreadyNarrowedType */
117+
if (method_exists($this->application, 'addCommand')) {
118+
$this->application->addCommand($command);
119+
120+
return;
121+
}
122+
123+
if (!$command instanceof Command) {
124+
throw new \InvalidArgumentException('Until we remove support for symfony console < 7.4, all commands must extend the base class');
125+
}
126+
127+
$this->application->add($command);
128+
}
129+
113130
/**
114131
* Build and execute the command tester.
115132
*

tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function setUp(): void
2323
->getMock();
2424

2525
$ndCommand = new NodeDumpCommand();
26-
$this->application->add($ndCommand);
26+
$this->addCommand($ndCommand);
2727
}
2828

2929
public function testCommand(): void

tests/PHPCR/Tests/Util/Console/Command/NodeMoveCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testCommand(array $args): void
3737
$this->session->expects($this->once())
3838
->method('save');
3939

40-
$this->application->add(new NodeMoveCommand());
40+
$this->addCommand(new NodeMoveCommand());
4141
$this->executeCommand('phpcr:node:move', $args);
4242
}
4343
}

tests/PHPCR/Tests/Util/Console/Command/NodeRemoveCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function setUp(): void
1212
{
1313
parent::setUp();
1414

15-
$this->application->add(new NodeRemoveCommand());
15+
$this->addCommand(new NodeRemoveCommand());
1616
}
1717

1818
public function testRemove(): void

tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function setUp(): void
2626
parent::setUp();
2727

2828
$command = new NodeTouchCommand();
29-
$this->application->add($command);
29+
$this->addCommand($command);
3030

3131
// Override default concrete instance with mock
3232
$this->phpcrHelper = $this->getMockBuilder(PhpcrHelper::class)

tests/PHPCR/Tests/Util/Console/Command/NodeTypeListCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setUp(): void
1919
{
2020
parent::setUp();
2121

22-
$this->application->add(new NodeTypeListCommand());
22+
$this->addCommand(new NodeTypeListCommand());
2323
$this->nodeTypeManager = $this->getMockBuilder(MockNodeTypeManager::class)
2424
->disableOriginalConstructor()
2525
->getMock();

tests/PHPCR/Tests/Util/Console/Command/NodeTypeRegisterCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setUp(): void
1919
{
2020
parent::setUp();
2121

22-
$this->application->add(new NodeTypeRegisterCommand());
22+
$this->addCommand(new NodeTypeRegisterCommand());
2323
$this->nodeTypeManager = $this->getMockBuilder(MockNodeTypeManager::class)
2424
->disableOriginalConstructor()
2525
->getMock();

0 commit comments

Comments
 (0)