Skip to content

Commit

Permalink
EWPP-3180: Fix failed tests related to changes in language switcher s…
Browse files Browse the repository at this point in the history
…ervices.
  • Loading branch information
sergepavle committed Mar 20, 2023
1 parent 818dce2 commit 7a8c871
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/src/Kernel/MultilingualAbstractKernelTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace Drupal\Tests\oe_theme\Kernel;

use Drupal\Core\Routing\RouteObjectInterface;
use Drupal\locale\SourceString;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;

/**
* Base class for multilingual tests.
Expand Down Expand Up @@ -56,6 +59,13 @@ protected function setUp(): void {
$this->container->get('module_handler')->loadInclude('oe_multilingual', 'install');
oe_multilingual_install(FALSE);

// In order to make it possible correctly render the language switcher block
// we have to provide the current route explicitly.
$request = Request::create('/');
$request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<front>');
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/'));
$this->container->get('request_stack')->push($request);

// Rebuild the container in order to make sure tests pass.
// @todo fix test setup so that we can get rid of this line.
$this->container->get('kernel')->rebuildContainer();
Expand Down

0 comments on commit 7a8c871

Please sign in to comment.