From 0391a434670bf34011b4e5bd4d2029fec6a56ac8 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 16 Feb 2024 22:20:45 +0100 Subject: [PATCH] Adjust for sf7 and new doctrine versions * drop annotations * adjust security to symfony 7 * ignore database creation failure because doctrine dbal decided to be a stickler * drop symfony 5 support --- .github/workflows/test-application.yaml | 42 +++----- CHANGELOG.md | 6 ++ bin/make/functional_tests_orm.mk | 2 +- bootstrap/bootstrap.php | 18 ---- composer.json | 30 +++--- phpunit.xml.dist | 19 ++-- resources/.travis.yml | 23 ----- resources/config/dist/framework.php | 19 +--- resources/config/dist/phpcr_odm.php | 2 +- resources/config/dist/security.php | 11 +-- src/Functional/BaseTestCase.php | 36 ++----- src/Functional/DbManager/ORM.php | 36 ++----- src/Functional/DbManager/PHPCR.php | 18 +--- src/Functional/DbManager/PhpcrDecorator.php | 6 ++ src/HttpKernel/TestKernel.php | 2 +- tests/Functional/BaseTestCaseTest.php | 104 +++++--------------- 16 files changed, 98 insertions(+), 276 deletions(-) delete mode 100644 resources/.travis.yml diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 5fefe4b..cfbf253 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -15,35 +15,22 @@ jobs: runs-on: ubuntu-20.04 env: - SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.symfony-deprecation-helper }} + SYMFONY_DEPRECATIONS_HELPER: weak SYMFONY_REQUIRE: ${{ matrix.symfony-version }} strategy: - fail-fast: false - matrix: - symfony-version: - - '*' - include: - - php-version: '7.1' - dependencies: 'lowest' - symfony-version: '^3.4' - symfony-deprecation-helper: 'weak' - - - php-version: '7.2' - - php-version: '7.3' - - php-version: '7.4' - symfony-version: '^4.4' - - php-version: '7.4' - symfony-version: '5.0.*' - - php-version: '8.0' - - php-version: '8.0' - symfony-version: '6.0.*' - - php-version: '8.2' - symfony-version: '7.0.*' + fail-fast: false + matrix: + include: + - php-version: '8.1' + dependencies: 'lowest' + - php-version: '8.1' + - php-version: '8.2' + - php-version: '8.3' steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -52,13 +39,12 @@ jobs: tools: 'composer:v2' - name: Install Symfony Flex - run: composer global require --no-progress --no-scripts --no-plugins symfony/flex - - - name: Allow Symfony Flex Plugin - run: composer global config --no-plugins allow-plugins.symfony/flex true + run: | + composer global require --no-progress --no-scripts --no-plugins symfony/flex + composer global config --no-plugins allow-plugins.symfony/flex true - name: Install dependencies with Composer - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependencies }} composer-options: --prefer-dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 332dc34..4f549dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========= +5.0.0 (unreleased) + +* Support Symfony 7, 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. + 4.4.2 ----- diff --git a/bin/make/functional_tests_orm.mk b/bin/make/functional_tests_orm.mk index 272369a..4c22f40 100644 --- a/bin/make/functional_tests_orm.mk +++ b/bin/make/functional_tests_orm.mk @@ -4,7 +4,7 @@ functional_tests_orm: @echo @echo '+++ create ORM database +++' @${CONSOLE} doctrine:schema:drop --env=orm --force - @${CONSOLE} doctrine:database:create --env=orm + @${CONSOLE} doctrine:database:create --env=orm || echo "Failed to create database. If this is sqlite, this is normal. Otherwise there will be an error with schema creation" @${CONSOLE} doctrine:schema:create --env=orm @echo '+++ run ORM functional tests +++' ifeq ($(HAS_XDEBUG), 0) diff --git a/bootstrap/bootstrap.php b/bootstrap/bootstrap.php index a478073..100d0f9 100644 --- a/bootstrap/bootstrap.php +++ b/bootstrap/bootstrap.php @@ -21,24 +21,6 @@ exit(1); } -use Doctrine\Common\Annotations\AnnotationRegistry; - -if (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader(function ($class) use ($loader) { - $loader->loadClass($class); - - // this was class_exists($class, false) i.e. do not autoload. - // this is required so that custom annotations (e.g. TreeUiBundle - // annotations) are autoloaded - but they should be found by the - // composer loader above. - // - // This probably slows things down. - // - // @todo: Fix me. - return class_exists($class); - }); -} - if (!defined('CMF_TEST_ROOT_DIR')) { define('CMF_TEST_ROOT_DIR', realpath(__DIR__.'/..')); } diff --git a/composer.json b/composer.json index df3de07..ef88379 100644 --- a/composer.json +++ b/composer.json @@ -9,22 +9,25 @@ } ], "require": { - "php": "^7.1|^8.0", + "php": "^8.1", "doctrine/data-fixtures": "^1.2", - "symfony/browser-kit": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0" + "symfony/browser-kit": "^6.4 || ^7.0" }, "require-dev": { "doctrine/doctrine-bundle": "^1.8 || ^2.0", - "doctrine/phpcr-bundle": "^1.3 || ^2.0.0 || ^3.0@beta", - "symfony/console": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/doctrine-bridge": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/framework-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/http-kernel": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", + "doctrine/phpcr-bundle": "^3.0", + "symfony/console": "^6.4 || ^7.0", + "symfony/dependency-injection": "^6.4 || ^7.0", + "symfony/doctrine-bridge": "^6.4 || ^7.0", + "symfony/framework-bundle": "^6.4 || ^7.0", + "symfony/http-kernel": "^6.4 || ^7.0", "symfony/monolog-bundle": "^3.5", - "symfony/security-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/twig-bundle": "^3.4.26 || ^4.3.8 || ^5.0 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^5.4" + "symfony/security-bundle": "^6.4 || ^7.0", + "symfony/twig-bundle": "^6.4 || ^7.0", + "symfony/phpunit-bridge": "^7.0.3" + }, + "conflict": { + "doctrine/phpcr-bundle": "<3.0" }, "autoload": { "psr-4": { @@ -41,10 +44,5 @@ "allow-plugins": { "composer/package-versions-deprecated": true } - }, - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f6973ee..d1e9538 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,18 @@ - - - - - ./tests - - + + + ./tests + + - diff --git a/resources/.travis.yml b/resources/.travis.yml deleted file mode 100644 index dd9412d..0000000 --- a/resources/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - -env: - - SYMFONY_VERSION=2.3.* - - SYMFONY_VERSION=2.4.* - - SYMFONY_VERSION=dev-master - -before_script: - - ./vendor/symfony-cmf/testing/bin/init-travis/phpcr_odm_doctrine_dbal.sh - -script: phpunit --coverage-text - -notifications: - irc: "irc.freenode.org#symfony-cmf" - email: "symfony-cmf-devs@googlegroups.com" - -matrix: - allow_failures: - - env: SYMFONY_VERSION=dev-master diff --git a/resources/config/dist/framework.php b/resources/config/dist/framework.php index e1a05e4..4928e61 100644 --- a/resources/config/dist/framework.php +++ b/resources/config/dist/framework.php @@ -9,36 +9,25 @@ * file that was distributed with this source code. */ -$routerPath = '%kernel.root_dir%/config/routing.php'; -if ($container->hasParameter('kernel.project_dir')) { - $routerPath = '%kernel.project_dir%/config/routing.php'; -} - $config = [ 'secret' => 'test', 'test' => null, 'form' => true, 'validation' => [ 'enabled' => true, - 'enable_annotations' => true, ], 'router' => [ - 'resource' => $routerPath, + 'resource' => '%kernel.project_dir%/config/routing.php', ], 'default_locale' => 'en', 'translator' => [ 'fallback' => 'en', ], + 'session' => [ + 'storage_factory_id' => 'session.storage.factory.mock_file', + ], ]; -if (interface_exists(\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface::class)) { - // Symfony 5.3+ - $config = array_merge($config, ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file']]); -} else { - // Symfony <5.3 - $config = array_merge($config, ['session' => ['storage_id' => 'session.storage.filesystem']]); -} - $container->loadFromExtension('framework', $config); $container->loadFromExtension('twig', [ diff --git a/resources/config/dist/phpcr_odm.php b/resources/config/dist/phpcr_odm.php index 75dc67a..4933d35 100644 --- a/resources/config/dist/phpcr_odm.php +++ b/resources/config/dist/phpcr_odm.php @@ -39,7 +39,7 @@ if (file_exists($phpcrOdmDocDir)) { $config['odm']['mappings']['test_additional'] = [ - 'type' => 'annotation', + 'type' => 'attribute', 'prefix' => $phpcrOdmDocPrefix, 'dir' => $phpcrOdmDocDir, 'is_bundle' => false, diff --git a/resources/config/dist/security.php b/resources/config/dist/security.php index 9651d85..f40d8b7 100644 --- a/resources/config/dist/security.php +++ b/resources/config/dist/security.php @@ -10,9 +10,6 @@ */ $config = [ - 'encoders' => [ - 'Symfony\Component\Security\Core\User\User' => 'plaintext', - ], 'role_hierarchy' => [ 'ROLE_ADMIN' => 'ROLE_USER', 'ROLE_SUPER_ADMIN' => ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'], @@ -40,13 +37,7 @@ ], ]; -if (class_exists(\Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider::class)) { - // Symfony <=5.4 - $config = array_merge($config, ['firewall' => ['main' => ['anonymous' => null]]]); -} - -if (interface_exists(\Symfony\Component\PasswordHasher\PasswordHasherInterface::class)) { - unset($config['encoders']); +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'], diff --git a/src/Functional/BaseTestCase.php b/src/Functional/BaseTestCase.php index 3097d44..da6cdda 100644 --- a/src/Functional/BaseTestCase.php +++ b/src/Functional/BaseTestCase.php @@ -12,13 +12,11 @@ namespace Symfony\Cmf\Component\Testing\Functional; use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager; -use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Cmf\Component\Testing\Functional\DbManager\ORM; use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR; use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\KernelInterface; @@ -32,15 +30,10 @@ abstract class BaseTestCase extends WebTestCase { /** * Use this property to save the DbManagers. - * - * @var array */ - protected $dbManagers = []; + protected array $dbManagers = []; - /** - * @var Client - */ - protected $client; + protected ?KernelBrowser $client = null; /** * Return the configuration to use when creating the Kernel. @@ -80,18 +73,6 @@ protected static function bootKernel(array $options = []): KernelInterface return parent::bootKernel(static::getKernelConfiguration()); } - /** - * BC with Symfony < 5.3 - when minimum version raises to ^5.3, we can remove this method. - */ - protected static function getContainer(): ContainerInterface - { - if (method_exists(KernelTestCase::class, 'getContainer')) { - return parent::getContainer(); - } - - return self::getKernel()->getContainer(); - } - protected static function getKernel(): KernelInterface { if (null === static::$kernel) { @@ -100,9 +81,7 @@ protected static function getKernel(): KernelInterface if (static::$kernel instanceof KernelInterface) { $kernelEnvironment = static::$kernel->getEnvironment(); - $expectedEnvironment = isset(static::getKernelConfiguration()['environment']) - ? static::getKernelConfiguration()['environment'] - : 'phpcr'; + $expectedEnvironment = static::getKernelConfiguration()['environment'] ?? 'phpcr'; if ($kernelEnvironment !== $expectedEnvironment) { var_dump($kernelEnvironment, $expectedEnvironment); static::bootKernel(); @@ -116,17 +95,14 @@ protected static function getKernel(): KernelInterface return static::$kernel; } - /** - * @return Client|KernelBrowser - */ - protected function getFrameworkBundleClient() + protected function getFrameworkBundleClient(): KernelBrowser { if (null === $this->client) { // property does not exist in all symfony versions if (property_exists(self::class, 'booted') && self::$booted) { self::ensureKernelShutdown(); } - $this->client = self::createClient($this->getKernelConfiguration()); + $this->client = self::createClient(self::getKernelConfiguration()); } return $this->client; @@ -174,7 +150,7 @@ protected function getDbManager(string $type) return $dbManager; } - protected static function assertResponseSuccess(Response $response) + protected static function assertResponseSuccess(Response $response): void { libxml_use_internal_errors(true); diff --git a/src/Functional/DbManager/ORM.php b/src/Functional/DbManager/ORM.php index 7753867..c72fd14 100644 --- a/src/Functional/DbManager/ORM.php +++ b/src/Functional/DbManager/ORM.php @@ -16,8 +16,6 @@ use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\ProxyReferenceRepository; use Doctrine\Common\DataFixtures\Purger\ORMPurger; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; @@ -32,49 +30,29 @@ */ class ORM { - /** - * @var ORMExecutor - */ - private $executor; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var ObjectManager - */ - protected $om; + private ORMExecutor $executor; + protected ContainerInterface $container; + protected ObjectManager $om; public function __construct(ContainerInterface $container) { $this->container = $container; } - /** - * @return ManagerRegistry|LegacyManagerRegistry - */ - public function getRegistry() + public function getRegistry(): ManagerRegistry { return $this->container->get('doctrine'); } - /** - * @return ObjectManager|LegacyObjectManager - */ - public function getOm($managerName = null) + public function getOm($managerName = null): ObjectManager { - if (!$this->om) { + if (!isset($this->om)) { $this->om = $this->getRegistry()->getManager($managerName); } return $this->om; } - /** - * Purge the database. - */ public function purgeDatabase(): void { $referenceRepository = new ProxyReferenceRepository($this->getOm()); @@ -125,7 +103,7 @@ protected function loadFixtureClass(Loader $loader, string $className): void private function getExecutor(): ORMExecutor { - if ($this->executor) { + if (isset($this->executor)) { return $this->executor; } diff --git a/src/Functional/DbManager/PHPCR.php b/src/Functional/DbManager/PHPCR.php index 5e3c4c6..6f34cbb 100644 --- a/src/Functional/DbManager/PHPCR.php +++ b/src/Functional/DbManager/PHPCR.php @@ -16,7 +16,6 @@ use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\ProxyReferenceRepository; use Doctrine\Common\DataFixtures\Purger\PHPCRPurger; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\Persistence\ManagerRegistry; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; @@ -26,25 +25,16 @@ class PHPCR { protected $container; - /** - * @var DocumentManager - */ - protected $om; + protected ?DocumentManager $om = null; - /** - * @var PHPCRExecutor - */ - private $executor; + private ?PHPCRExecutor $executor = null; public function __construct(ContainerInterface $container) { $this->container = $container; } - /** - * @return ManagerRegistry|LegacyManagerRegistry - */ - public function getRegistry() + public function getRegistry(): ManagerRegistry { return $this->container->get('doctrine_phpcr'); } @@ -78,7 +68,7 @@ public function loadFixtures(array $classNames, bool $initialize = false): void $this->getExecutor($initialize)->execute($loader->getFixtures(), false); } - public function loadFixtureClass(Loader $loader, string $className) + public function loadFixtureClass(Loader $loader, string $className): void { if (!class_exists($className)) { throw new \InvalidArgumentException(sprintf( diff --git a/src/Functional/DbManager/PhpcrDecorator.php b/src/Functional/DbManager/PhpcrDecorator.php index 14b1a7d..c1ab08b 100644 --- a/src/Functional/DbManager/PhpcrDecorator.php +++ b/src/Functional/DbManager/PhpcrDecorator.php @@ -13,6 +13,7 @@ use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager; use Doctrine\ODM\PHPCR\DocumentManagerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * A decorator around the DoctrinePHPCRBundle RepositoryManager class to @@ -20,6 +21,11 @@ */ class PhpcrDecorator extends RepositoryManager { + public function __construct(ContainerInterface $container) + { + parent::__construct($container->get('doctrine_phpcr'), $container->get('doctrine_phpcr.initializer_manager')); + } + public function getOm(string $managerName = null): DocumentManagerInterface { return $this->getDocumentManager($managerName); diff --git a/src/HttpKernel/TestKernel.php b/src/HttpKernel/TestKernel.php index 16ba132..8092d5b 100644 --- a/src/HttpKernel/TestKernel.php +++ b/src/HttpKernel/TestKernel.php @@ -214,7 +214,7 @@ protected function registerConfiguredBundles() } } - protected function build(ContainerBuilder $container) + protected function build(ContainerBuilder $container): void { parent::build($container); if (\in_array($this->getEnvironment(), ['test', 'phpcr']) && file_exists($this->getKernelDir().'/config/public_services.php')) { diff --git a/tests/Functional/BaseTestCaseTest.php b/tests/Functional/BaseTestCaseTest.php index e9c293e..f9f8ccd 100644 --- a/tests/Functional/BaseTestCaseTest.php +++ b/tests/Functional/BaseTestCaseTest.php @@ -11,26 +11,25 @@ namespace Symfony\Cmf\Component\Testing\Tests\Functional; -use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager; +use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager; +use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Client; 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\ContainerInterface; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpKernel\KernelInterface; class BaseTestCaseTest extends TestCase { /** - * @var ContainerInterface|MockObject + * @var Container&MockObject */ private $container; /** - * @var KernelInterface|MockObject + * @var KernelInterface&MockObject */ private $kernel; @@ -40,27 +39,33 @@ class BaseTestCaseTest extends TestCase private $testCase; /** - * @var KernelBrowser|Client|MockObject + * @var KernelBrowser&MockObject */ private $client; protected function setUp(): void { - $this->container = $this->createMock(ContainerInterface::class); - $this->container->expects($this->any()) + $managerRegistry = $this->createMock(ManagerRegistryInterface::class); + $initializerManager = $this->createMock(InitializerManager::class); + $this->container = $this->createMock(Container::class); + $this->container ->method('get') - ->will($this->returnCallback(function ($name) { - $dic = ['test.client' => $this->client]; + ->willReturnCallback(function ($name) use ($managerRegistry, $initializerManager) { + $dic = [ + 'test.client' => $this->client, + 'doctrine_phpcr' => $managerRegistry, + 'doctrine_phpcr.initializer_manager' => $initializerManager, + ]; return $dic[$name]; - })); + }); $this->kernel = $this->createMock(KernelInterface::class); - $this->kernel->expects($this->any()) + $this->kernel ->method('getContainer') ->willReturn($this->container) ; - $this->kernel->expects($this->any()) + $this->kernel ->method('getEnvironment') ->willReturn('phpcr') ; @@ -68,27 +73,13 @@ protected function setUp(): void $this->testCase = new TestTestCase(); $this->testCase->setKernel($this->kernel); - if (class_exists(KernelBrowser::class)) { - $this->client = $this->createMock(KernelBrowser::class); - } else { - $this->client = $this->createMock(Client::class); - } - - $this->client->expects($this->any()) + $this->client = $this->createMock(KernelBrowser::class); + $this->client ->method('getContainer') ->willReturn($this->container); } - public function testGetContainer() - { - $class = new \ReflectionClass(BaseTestCase::class); - $method = $class->getMethod('getContainer'); - $method->setAccessible(true); - - $this->assertEquals($this->container, $method->invoke(null)); - } - - public function testGetKernel() + public function testGetKernel(): void { $class = new \ReflectionClass(BaseTestCase::class); $method = $class->getMethod('getKernel'); @@ -97,59 +88,12 @@ public function testGetKernel() $this->assertInstanceOf(KernelInterface::class, $method->invoke(null)); } - public function testItCanProvideAFrameworkBundleClient() + public function testItCanProvideAFrameworkBundleClient(): void { $class = new \ReflectionClass(BaseTestCase::class); $method = $class->getMethod('getFrameworkBundleClient'); $method->setAccessible(true); - if (class_exists(KernelBrowser::class)) { - $this->assertInstanceOf(KernelBrowser::class, $method->invoke($this->testCase)); - } else { - $this->assertInstanceOf(Client::class, $method->invoke($this->testCase)); - } - } - - public function provideTestDb() - { - return [ - ['PHPCR', 'PHPCR'], - ['Phpcr', 'PHPCR'], - ['ORM', 'ORM'], - ['foobar', null], - ]; - } - - /** - * @dataProvider provideTestDb - * - * @depends testGetContainer - */ - 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); + $this->assertInstanceOf(KernelBrowser::class, $method->invoke($this->testCase)); } }