Skip to content

Commit 05a1992

Browse files
authored
Merge pull request #219 from symfony-cmf/sf7
support symfony 7
2 parents 3b52fcb + 613197b commit 05a1992

File tree

8 files changed

+54
-73
lines changed

8 files changed

+54
-73
lines changed

.github/workflows/test-application.yaml

+11-18
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
symfony-version:
24-
- '*'
2523
include:
26-
- php-version: '7.1'
24+
- php-version: '7.2'
2725
dependencies: 'lowest'
28-
symfony-version: '^3.4'
26+
symfony-version: '^5.4'
2927
symfony-deprecation-helper: 'weak'
30-
31-
- php-version: '7.2'
3228
- php-version: '7.3'
29+
symfony-version: '*'
3330
- php-version: '7.4'
34-
symfony-version: '^4.4'
35-
- php-version: '7.4'
36-
symfony-version: '5.0.*'
37-
- php-version: '8.0'
31+
symfony-version: '^5.4'
3832
- php-version: '8.0'
3933
symfony-version: '6.0.*'
40-
34+
- php-version: '8.1'
35+
symfony-version: '^6.4'
36+
- php-version: '8.2'
37+
symfony-version: '*'
38+
- php-version: '8.3'
39+
symfony-version: '^7.0'
4140
steps:
4241
- name: Checkout project
4342
uses: actions/checkout@v2
@@ -46,13 +45,7 @@ jobs:
4645
uses: shivammathur/setup-php@v2
4746
with:
4847
php-version: ${{ matrix.php-version }}
49-
tools: 'composer:v2'
50-
51-
- name: Install Symfony Flex
52-
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex
53-
54-
- name: Allow Symfony Flex Plugin
55-
run: composer global config --no-plugins allow-plugins.symfony/flex true
48+
tools: composer:v2, flex
5649

5750
- name: Install dependencies with Composer
5851
uses: ramsey/composer-install@v1

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Changelog
44
4.x
55
===
66

7-
4.4.3
7+
4.5.0
88
-----
99

1010
* Support phpcr-bundle 3.
11+
* Support Symfony 7.
12+
* Drop support for Symfony < 5.4.
1113

1214
4.4.2
1315
-----

composer.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,26 @@
99
}
1010
],
1111
"require": {
12-
"php": "^7.1|^8.0",
12+
"php": "^7.2|^8.0",
1313
"doctrine/data-fixtures": "^1.2",
14-
"symfony/browser-kit": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0"
14+
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0"
1515
},
1616
"require-dev": {
1717
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
1818
"doctrine/phpcr-bundle": "^1.3 || ^2.0 || ^3.0",
19-
"symfony/console": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
20-
"symfony/dependency-injection": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
21-
"symfony/doctrine-bridge": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
22-
"symfony/framework-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
23-
"symfony/http-kernel": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
19+
"symfony/console": "^5.4 || ^6.0 || ^7.0",
20+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
21+
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
22+
"symfony/framework-bundle": "^5.4.6 || ^6.0 || ^7.0",
23+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
2424
"symfony/monolog-bundle": "^3.5",
25-
"symfony/security-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
26-
"symfony/twig-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0",
27-
"symfony/phpunit-bridge": "^5.4"
25+
"symfony/security-bundle": "^5.4 || ^6.0 || ^7.0",
26+
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
27+
"symfony/phpunit-bridge": "^7.0.6",
28+
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
29+
},
30+
"conflict": {
31+
"symfony/framework-bundle": "<5.4.6"
2832
},
2933
"autoload": {
3034
"psr-4": {

resources/config/dist/framework.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616

1717
$config = [
1818
'secret' => 'test',
19-
'test' => null,
19+
'test' => true,
2020
'form' => true,
2121
'validation' => [
2222
'enabled' => true,
23-
'enable_annotations' => true,
2423
],
2524
'router' => [
2625
'resource' => $routerPath,
@@ -29,14 +28,14 @@
2928
'translator' => [
3029
'fallback' => 'en',
3130
],
31+
'session' => [
32+
'storage_factory_id' => 'session.storage.factory.mock_file',
33+
],
3234
];
3335

34-
if (interface_exists(\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface::class)) {
35-
// Symfony 5.3+
36-
$config = array_merge($config, ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file']]);
37-
} else {
38-
// Symfony <5.3
39-
$config = array_merge($config, ['session' => ['storage_id' => 'session.storage.filesystem']]);
36+
if (class_exists(\Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::class)) {
37+
// Symfony < 7
38+
$config['validation']['enable_annotations'] = true;
4039
}
4140

4241
$container->loadFromExtension('framework', $config);

resources/config/dist/security.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@
4141
];
4242

4343
if (class_exists(\Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider::class)) {
44-
// Symfony <=5.4
44+
// Symfony 5.4
4545
$config = array_merge($config, ['firewall' => ['main' => ['anonymous' => null]]]);
4646
}
4747

4848
if (interface_exists(\Symfony\Component\PasswordHasher\PasswordHasherInterface::class)) {
4949
unset($config['encoders']);
50-
$config = array_merge($config, [
51-
'enable_authenticator_manager' => true,
52-
'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
53-
]);
50+
$config['password_hashers'] = ['Symfony\Component\Security\Core\User\User' => 'plaintext'];
51+
if (class_exists(\Symfony\Component\Security\Core\Security::class)) {
52+
// Symfony 6 but not 7
53+
$config['enable_authenticator_manager'] = true;
54+
}
5455
}
5556

5657
$container->loadFromExtension('security', $config);

src/Functional/BaseTestCase.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Cmf\Component\Testing\Functional\DbManager\ORM;
1919
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
2020
use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator;
21-
use Symfony\Component\DependencyInjection\ContainerInterface;
2221
use Symfony\Component\HttpFoundation\Response;
2322
use Symfony\Component\HttpKernel\KernelInterface;
2423

@@ -80,18 +79,6 @@ protected static function bootKernel(array $options = []): KernelInterface
8079
return parent::bootKernel(static::getKernelConfiguration());
8180
}
8281

83-
/**
84-
* BC with Symfony < 5.3 - when minimum version raises to ^5.3, we can remove this method.
85-
*/
86-
protected static function getContainer(): ContainerInterface
87-
{
88-
if (method_exists(KernelTestCase::class, 'getContainer')) {
89-
return parent::getContainer();
90-
}
91-
92-
return self::getKernel()->getContainer();
93-
}
94-
9582
protected static function getKernel(): KernelInterface
9683
{
9784
if (null === static::$kernel) {
@@ -100,9 +87,7 @@ protected static function getKernel(): KernelInterface
10087

10188
if (static::$kernel instanceof KernelInterface) {
10289
$kernelEnvironment = static::$kernel->getEnvironment();
103-
$expectedEnvironment = isset(static::getKernelConfiguration()['environment'])
104-
? static::getKernelConfiguration()['environment']
105-
: 'phpcr';
90+
$expectedEnvironment = static::getKernelConfiguration()['environment'] ?? 'phpcr';
10691
if ($kernelEnvironment !== $expectedEnvironment) {
10792
var_dump($kernelEnvironment, $expectedEnvironment);
10893
static::bootKernel();

src/HttpKernel/TestKernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected function registerConfiguredBundles()
214214
}
215215
}
216216

217-
protected function build(ContainerBuilder $container)
217+
protected function build(ContainerBuilder $container): void
218218
{
219219
parent::build($container);
220220
if (\in_array($this->getEnvironment(), ['test', 'phpcr']) && file_exists($this->getKernelDir().'/config/public_services.php')) {

tests/Functional/BaseTestCaseTest.php

+11-14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Component\Testing\Tests\Functional;
1313

1414
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
15+
use Doctrine\Bundle\PHPCRBundle\ManagerRegistry;
1516
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
1617
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
1718
use PHPUnit\Framework\MockObject\MockObject;
@@ -21,7 +22,9 @@
2122
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
2223
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
2324
use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase;
25+
use Symfony\Component\DependencyInjection\Container;
2426
use Symfony\Component\DependencyInjection\ContainerInterface;
27+
use Symfony\Component\HttpKernel\Kernel;
2528
use Symfony\Component\HttpKernel\KernelInterface;
2629

2730
class BaseTestCaseTest extends TestCase
@@ -48,13 +51,18 @@ class BaseTestCaseTest extends TestCase
4851

4952
protected function setUp(): void
5053
{
51-
$this->container = $this->createMock(ContainerInterface::class);
54+
$managerRegistry = interface_exists(ManagerRegistryInterface::class)
55+
? $this->createMock(ManagerRegistryInterface::class)
56+
: $this->createMock(ManagerRegistry::class)
57+
;
58+
$this->container = Kernel::MAJOR_VERSION >= 7 ? $this->createMock(Container::class) : $this->createMock(ContainerInterface::class);
5259
$this->container
5360
->method('get')
54-
->willReturnCallback(function ($name) {
61+
->willReturnCallback(function ($name) use ($managerRegistry) {
5562
$dic = [
5663
'test.client' => $this->client,
57-
'doctrine_phpcr' => $this->createMock(ManagerRegistryInterface::class),
64+
'test.service_container' => $this->container,
65+
'doctrine_phpcr' => $managerRegistry,
5866
'doctrine_phpcr.initializer_manager' => $this->createMock(InitializerManager::class),
5967
];
6068

@@ -85,15 +93,6 @@ protected function setUp(): void
8593
->willReturn($this->container);
8694
}
8795

88-
public function testGetContainer()
89-
{
90-
$class = new \ReflectionClass(BaseTestCase::class);
91-
$method = $class->getMethod('getContainer');
92-
$method->setAccessible(true);
93-
94-
$this->assertEquals($this->container, $method->invoke(null));
95-
}
96-
9796
public function testGetKernel()
9897
{
9998
$class = new \ReflectionClass(BaseTestCase::class);
@@ -128,8 +127,6 @@ public function provideTestDb()
128127

129128
/**
130129
* @dataProvider provideTestDb
131-
*
132-
* @depends testGetContainer
133130
*/
134131
public function testDb($dbName, $expected)
135132
{

0 commit comments

Comments
 (0)