Uploaded image for project: 'Ibexa IBX'
  1. Ibexa IBX
  2. IBX-7328

IbexaTestKernel: Wrong bundle registration order for ChainRouter

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium
    • Customer request
    • 3.3.36, 4.5.4
    • Open Source
    • 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.

      Designs

        Attachments

          Activity

            People

              andrew.longosz@ibexa.co Andrew Longosz
              thorsten.reiter@ibexa.co Thorsten Reiter
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: