diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index bafb2b9..22ce986 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -23,6 +23,7 @@ jobs: include: - php-version: '8.1' dependencies: 'lowest' + symfony-version: '^6.4' - php-version: '8.1' - php-version: '8.2' - php-version: '8.3' @@ -35,12 +36,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - tools: 'composer:v2' - - - name: Install Symfony Flex - run: | - composer global require --no-progress --no-scripts --no-plugins symfony/flex - composer global config --no-plugins allow-plugins.symfony/flex true + tools: composer:v2, flex - name: Install dependencies with Composer uses: ramsey/composer-install@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index bad45b0..5c7619a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,23 @@ Changelog 5.x === -5.0.0 +5.0.0 ----- -* Support Symfony 7, drop support for Symfony < 6.4 +* Drop support for Symfony < 6.4 * The default framework configuration no longer enables validation attributes. -* The phpcr-odm additional namespace is expected to use attributes rather than annotations. +* The PHPCR-ODM additional namespace is expected to use attributes rather than annotations. 4.x === +4.5.0 +----- + +* Support phpcr-bundle 3. +* Support Symfony 7. +* Drop support for Symfony < 5.4. + 4.4.2 ----- diff --git a/composer.json b/composer.json index ef88379..7321256 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "symfony/phpunit-bridge": "^7.0.3" }, "conflict": { - "doctrine/phpcr-bundle": "<3.0" + "doctrine/phpcr-bundle": "<3.0", + "symfony/framework-bundle": "<5.4.6" }, "autoload": { "psr-4": { diff --git a/resources/config/dist/framework.php b/resources/config/dist/framework.php index 4928e61..bf9c84e 100644 --- a/resources/config/dist/framework.php +++ b/resources/config/dist/framework.php @@ -11,7 +11,7 @@ $config = [ 'secret' => 'test', - 'test' => null, + 'test' => true, 'form' => true, 'validation' => [ 'enabled' => true, diff --git a/resources/config/dist/security.php b/resources/config/dist/security.php index f40d8b7..3008522 100644 --- a/resources/config/dist/security.php +++ b/resources/config/dist/security.php @@ -35,13 +35,15 @@ ], ], ], + 'password_hashers' => [ + 'Symfony\Component\Security\Core\User\User' => 'plaintext', + ], ]; + if (class_exists(\Symfony\Component\Security\Core\Security::class)) { - $config = array_merge($config, [ - 'enable_authenticator_manager' => true, - 'password_hashers' => ['Symfony\Component\Security\Core\User\User' => 'plaintext'], - ]); + // Symfony 6 but not 7 + $config['enable_authenticator_manager'] = true; } $container->loadFromExtension('security', $config); diff --git a/src/Functional/BaseTestCase.php b/src/Functional/BaseTestCase.php index da6cdda..9d7b66e 100644 --- a/src/Functional/BaseTestCase.php +++ b/src/Functional/BaseTestCase.php @@ -143,7 +143,14 @@ protected function getDbManager(string $type) )); } - $dbManager = new $className($this->getContainer()); + $refl = new \ReflectionClass($className); + if (1 === $refl->getConstructor()->getNumberOfParameters()) { + // phpcr-bundle < 3 + $dbManager = new $className(self::getContainer()); + } else { + // phpcr-bundle >= 3 + $dbManager = new $className(self::getContainer()->get('doctrine_phpcr'), self::getContainer()->get('doctrine_phpcr.initializer_manager')); + } $this->dbManagers[$type] = $dbManager; diff --git a/tests/Functional/BaseTestCaseTest.php b/tests/Functional/BaseTestCaseTest.php index f9f8ccd..f441da7 100644 --- a/tests/Functional/BaseTestCaseTest.php +++ b/tests/Functional/BaseTestCaseTest.php @@ -13,6 +13,7 @@ use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager; use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface; +use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\KernelBrowser; @@ -53,6 +54,7 @@ protected function setUp(): void ->willReturnCallback(function ($name) use ($managerRegistry, $initializerManager) { $dic = [ 'test.client' => $this->client, + 'test.service_container' => $this->container, 'doctrine_phpcr' => $managerRegistry, 'doctrine_phpcr.initializer_manager' => $initializerManager, ]; @@ -74,6 +76,7 @@ protected function setUp(): void $this->testCase->setKernel($this->kernel); $this->client = $this->createMock(KernelBrowser::class); + $this->client ->method('getContainer') ->willReturn($this->container); @@ -96,4 +99,45 @@ public function testItCanProvideAFrameworkBundleClient(): void $this->assertInstanceOf(KernelBrowser::class, $method->invoke($this->testCase)); } + + public function provideTestDb() + { + return [ + ['PHPCR', 'PHPCR'], + ['Phpcr', 'PHPCR'], + ['ORM', 'ORM'], + ['foobar', null], + ]; + } + + /** + * @dataProvider provideTestDb + */ + public function testDb($dbName, $expected) + { + $class = new \ReflectionClass(BaseTestCase::class); + $method = $class->getMethod('getDbManager'); + $method->setAccessible(true); + + if (null === $expected) { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage($dbName.'" does not exist'); + } + + $res = $method->invoke($this->testCase, $dbName); + if (null === $expected) { + // do not do assertions if the expected exception has not been thrown. + return; + } + + $className = sprintf( + 'Symfony\Cmf\Component\Testing\Functional\DbManager\%s', + $expected + ); + if (PHPCR::class === $className && class_exists(RepositoryManager::class)) { + $className = RepositoryManager::class; + } + + $this->assertInstanceOf($className, $res); + } }