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..12d8681 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,9 @@ "symfony/phpunit-bridge": "^7.0.3" }, "conflict": { - "doctrine/phpcr-bundle": "<3.0" + "doctrine/phpcr-odm": "<2.0", + "doctrine/phpcr-bundle": "<3.0", + "symfony/framework-bundle": "<6.4" }, "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..57d1dc1 100644 --- a/resources/config/dist/security.php +++ b/resources/config/dist/security.php @@ -35,13 +35,14 @@ ], ], ], + '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..022559e 100644 --- a/src/Functional/BaseTestCase.php +++ b/src/Functional/BaseTestCase.php @@ -143,7 +143,7 @@ protected function getDbManager(string $type) )); } - $dbManager = new $className($this->getContainer()); + $dbManager = new $className(self::getContainer()); $this->dbManagers[$type] = $dbManager; diff --git a/tests/Functional/BaseTestCaseTest.php b/tests/Functional/BaseTestCaseTest.php index f9f8ccd..34ad8c3 100644 --- a/tests/Functional/BaseTestCaseTest.php +++ b/tests/Functional/BaseTestCaseTest.php @@ -13,10 +13,12 @@ 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; use Symfony\Cmf\Component\Testing\Functional\BaseTestCase; +use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR; use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpKernel\KernelInterface; @@ -53,6 +55,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 +77,7 @@ protected function setUp(): void $this->testCase->setKernel($this->kernel); $this->client = $this->createMock(KernelBrowser::class); + $this->client ->method('getContainer') ->willReturn($this->container); @@ -83,7 +87,6 @@ public function testGetKernel(): void { $class = new \ReflectionClass(BaseTestCase::class); $method = $class->getMethod('getKernel'); - $method->setAccessible(true); $this->assertInstanceOf(KernelInterface::class, $method->invoke(null)); } @@ -92,8 +95,47 @@ public function testItCanProvideAFrameworkBundleClient(): void { $class = new \ReflectionClass(BaseTestCase::class); $method = $class->getMethod('getFrameworkBundleClient'); - $method->setAccessible(true); $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'); + + 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); + } }