Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
3.3.36, 4.5.4
-
None
-
Ibexa Commerce, Ibexa Content, Ibexa Experience, Ibexa Open Source
-
Yes
Description
Setup test as following:
tests/Integration/ExampleTest.php
<?php declare(strict_types=1); namespace App\Tests\Integration; use Ibexa\Contracts\Core\Test\IbexaKernelTestCase; use Ibexa\Contracts\Core\Test\IbexaTestKernel; use Ibexa\Core\MVC\Symfony\Routing\ChainRouter; final class ExampleTest extends IbexaKernelTestCase { public function testExample(): void { self::assertInstanceOf( ChainRouter::class, self::bootKernel()->getContainer()->get('router'), ); } protected static function getKernelClass(): string { return IbexaTestKernel::class; } }
Run test:
php bin/phpunit
==>
There was 1 failure: 1) App\Tests\Integration\ExampleTest::testExample Failed asserting that "Ibexa\Bundle\Core\Routing\DefaultRouter" Object (...) is an instance of class "Ibexa\Core\MVC\Symfony\Routing\ChainRouter". /var/www/html/tests/Integration/ExampleTest.php:17
Note:
Behaviour is caused by a different order of bundle registrations in config/bundles.php vs vendor/ibexa/core/src/contracts/Test/IbexaTestKernel.php
config/bundles.php
<?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], .... Ibexa\Bundle\Core\IbexaCoreBundle::class => ['all' => true],
vendor/ibexa/core/src/contracts/Test/IbexaTestKernel.php
public function registerBundles(): iterable { yield new SecurityBundle(); yield new IbexaCoreBundle(); // <--- yield new IbexaLegacySearchEngineBundle(); yield new JMSTranslationBundle(); yield new FOSJsRoutingBundle(); yield new FrameworkBundle(); // <--- yield new LiipImagineBundle(); yield new TwigBundle(); yield new DoctrineBundle(); }
Note (2):
Same applies for Ibexa\Contracts\Test\Core\IbexaTestKernel from ibexa/test-core bundle.