10000 Merge remote-tracking branch 'origin/4.x' into 4-to-5 · symfony-cmf/Testing@af24cbb · GitHub
[go: up one dir, main page]

Skip to content

Commit af24cbb

Browse files
committed
Merge remote-tracking branch 'origin/4.x' into 4-to-5
2 parents 9be0bcd + 05a1992 commit af24cbb

File tree

7 files changed

+73
-16
lines changed

7 files changed

+73
-16
lines changed

.github/workflows/test-application.yaml

Lines changed: 2 additions & 6 deletions
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

Lines changed: 10 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"symfony/phpunit-bridge": "^7.0.3"
2828
},
2929
"conflict": {
30-
"doctrine/phpcr-bundle": "<3.0"
30+
"doctrine/phpcr-bundle": "<3.0",
31+
"symfony/framework-bundle": "<5.4.6"
3132
},
3233
"autoload": {
3334
"psr-4": {

resources/config/dist/framework.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
],
3636
],
3737
],
38+
'password_hashers' => [
39+
'Symfony\Component\Security\Core\User\User' => 'plaintext',
40+
],
3841
];
3942

43+
4044
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-
]);
45+
// Symfony 6 but not 7
46+
$config['enable_authenticator_manager'] = true;
4547
}
4648

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

src/Functional/BaseTestCase.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ protected function getDbManager(string $type)
143143
));
144144
}
145145

146-
$dbManager = new $className($this->getContainer());
146+
$refl = new \ReflectionClass($className);
147+
if (1 === $refl->getConstructor()->getNumberOfParameters()) {
148+
// phpcr-bundle < 3
149+
$dbManager = new $className(self::getContainer());
150+
} else {
151+
// phpcr-bundle >= 3
152+
$dbManager = new $className(self::getContainer()->get('doctrine_phpcr'), self::getContainer()->get('doctrine_phpcr.initializer_manager'));
153+
}
147154

148155
$this->dbManagers[$type] = $dbManager;
149156

tests/Functional/BaseTestCaseTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
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;
@@ -53,6 +54,7 @@ protected function setUp(): void
5354
->willReturnCallback(function ($name) use ($managerRegistry, $initializerManager) {
5455
$dic = [
5556
'test.client' => $this->client,
57+
'test.service_container' => $this->container,
5658
'doctrine_phpcr' => $managerRegistry,
5759
'doctrine_phpcr.initializer_manager' => $initializerManager,
5860
];
@@ -74,6 +76,7 @@ protected function setUp(): void
7476
$this->testCase->setKernel($this->kernel);
7577

7678
$this->client = $this->createMock(KernelBrowser::class);
79+
7780
$this->client
7881
->method('getContainer')
7982
->willReturn($this->container);
@@ -96,4 +99,45 @@ public function testItCanProvideAFrameworkBundleClient(): void
9699

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

0 commit comments

Comments
 (0)
0