Skip to content

Commit d00ae5a

Browse files
authored
Merge pull request #220 from symfony-cmf/4-to-5
4 to 5
2 parents 9be0bcd + a00c429 commit d00ae5a

File tree

7 files changed

+66
-18
lines changed

7 files changed

+66
-18
lines changed

.github/workflows/test-application.yaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
include:
2424
- php-version: '8.1'
2525
dependencies: 'lowest'
26+
symfony-version: '^6.4'
2627
- php-version: '8.1'
2728
- php-version: '8.2'
2829
- php-version: '8.3'
@@ -35,12 +36,7 @@ jobs:
3536
uses: shivammathur/setup-php@v2
3637
with:
3738
php-version: ${{ matrix.php-version }}
38-
tools: 'composer:v2'
39-
40-
- name: Install Symfony Flex
41-
run: |
42-
composer global require --no-progress --no-scripts --no-plugins symfony/flex
43-
composer global config --no-plugins allow-plugins.symfony/flex true
39+
tools: composer:v2, flex
4440

4541
- name: Install dependencies with Composer
4642
uses: ramsey/composer-install@v2

CHANGELOG.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ Changelog
44
5.x
55
===
66

7-
5.0.0
7+
5.0.0
88
-----
99

10-
* Support Symfony 7, drop support for Symfony < 6.4
10+
* Drop support for Symfony < 6.4
1111
* The default framework configuration no longer enables validation attributes.
12-
* The phpcr-odm additional namespace is expected to use attributes rather than annotations.
12+
* The PHPCR-ODM additional namespace is expected to use attributes rather than annotations.
1313

1414
4.x
1515
===
1616

17+
4.5.0
18+
-----
19+
20+
* Support phpcr-bundle 3.
21+
* Support Symfony 7.
22+
* Drop support for Symfony < 5.4.
23+
1724
4.4.2
1825
-----
1926

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"symfony/phpunit-bridge": "^7.0.3"
2828
},
2929
"conflict": {
30-
"doctrine/phpcr-bundle": "<3.0"
30+
"doctrine/phpcr-odm": "<2.0",
31+
"doctrine/phpcr-bundle": "<3.0",
32+
"symfony/framework-bundle": "<6.4"
3133
},
3234
"autoload": {
3335
"psr-4": {

resources/config/dist/framework.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
$config = [
1313
'secret' => 'test',
14-
'test' => null,
14+
'test' => true,
1515
'form' => true,
1616
'validation' => [
1717
'enabled' => true,

resources/config/dist/security.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
],
3636
],
3737
],
38+
'password_hashers' => [
39+
'Symfony\Component\Security\Core\User\User' => 'plaintext',
40+
],
3841
];
3942

4043
if (class_exists(\Symfony\Component\Security\Core\Security::class)) {
41-
$config = array_merge($config, [
42-
'enable_authenticator_manager' => true,
43-
'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'],
44-
]);
44+
// Symfony 6 but not 7
45+
$config['enable_authenticator_manager'] = true;
4546
}
4647

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

src/Functional/BaseTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function getDbManager(string $type)
143143
));
144144
}
145145

146-
$dbManager = new $className($this->getContainer());
146+
$dbManager = new $className(self::getContainer());
147147

148148
$this->dbManagers[$type] = $dbManager;
149149

tests/Functional/BaseTestCaseTest.php

+44-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313

1414
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
1515
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
16+
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
1819
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1920
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
21+
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
2022
use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase;
2123
use Symfony\Component\DependencyInjection\Container;
2224
use Symfony\Component\HttpKernel\KernelInterface;
@@ -53,6 +55,7 @@ protected function setUp(): void
5355
->willReturnCallback(function ($name) use ($managerRegistry, $initializerManager) {
5456
$dic = [
5557
'test.client' => $this->client,
58+
'test.service_container' => $this->container,
5659
'doctrine_phpcr' => $managerRegistry,
5760
'doctrine_phpcr.initializer_manager' => $initializerManager,
5861
];
@@ -74,6 +77,7 @@ protected function setUp(): void
7477
$this->testCase->setKernel($this->kernel);
7578

7679
$this->client = $this->createMock(KernelBrowser::class);
80+
7781
$this->client
7882
->method('getContainer')
7983
->willReturn($this->container);
@@ -83,7 +87,6 @@ public function testGetKernel(): void
8387
{
8488
$class = new \ReflectionClass(BaseTestCase::class);
8589
$method = $class->getMethod('getKernel');
86-
$method->setAccessible(true);
8790

8891
$this->assertInstanceOf(KernelInterface::class, $method->invoke(null));
8992
}
@@ -92,8 +95,47 @@ public function testItCanProvideAFrameworkBundleClient(): void
9295
{
9396
$class = new \ReflectionClass(BaseTestCase::class);
9497
$method = $class->getMethod('getFrameworkBundleClient');
95-
$method->setAccessible(true);
9698

9799
$this->assertInstanceOf(KernelBrowser::class, $method->invoke($this->testCase));
98100
}
101+
102+
public function provideTestDb()
103+
{
104+
return [
105+
['PHPCR', 'PHPCR'],
106+
['Phpcr', 'PHPCR'],
107+
['ORM', 'ORM'],
108+
['foobar', null],
109+
];
110+
}
111+
112+
/**
113+
* @dataProvider provideTestDb
114+
*/
115+
public function testDb($dbName, $expected)
116+
{
117+
$class = new \ReflectionClass(BaseTestCase::class);
118+
$method = $class->getMethod('getDbManager');
119+
120+
if (null === $expected) {
121+
$this->expectException('InvalidArgumentException');
122+
$this->expectExceptionMessage($dbName.'" does not exist');
123+
}
124+
125+
$res = $method->invoke($this->testCase, $dbName);
126+
if (null === $expected) {
127+
// do not do assertions if the expected exception has not been thrown.
128+
return;
129+
}
130+
131+
$className = sprintf(
132+
'Symfony\Cmf\Component\Testing\Functional\DbManager\%s',
133+
$expected
134+
);
135+
if (PHPCR::class === $className && class_exists(RepositoryManager::class)) {
136+
$className = RepositoryManager::class;
137+
}
138+
139+
$this->assertInstanceOf($className, $res);
140+
}
99141
}

0 commit comments

Comments
 (0)