You are here

public function EntityReferenceNormalizerTest::alter in Commerce Cart API 8

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceModifierInterface::alter

File

tests/src/Kernel/Normalizer/EntityReferenceNormalizerTest.php, line 79

Class

EntityReferenceNormalizerTest
@group commerce_cart_api

Namespace

Drupal\Tests\commerce_cart_api\Kernel\Normalizer

Code

public function alter(ContainerBuilder $container) {

  // Remove commerce_order.order_store_resolver.
  // \Drupalcommerce_price\CurrencyFormatter is constructed and runs locale
  // resolving which kicks off discovering the current country, which ends up
  // running the store resolver. The OrderStoreResolver tries to get the
  // order parameter which we do not have mocked.
  $container
    ->removeDefinition('commerce_order.order_store_resolver');
  $mocked_route_match = $this
    ->prophesize(RouteMatchInterface::class);
  $mocked_route = $this
    ->prophesize(Route::class);
  $mocked_route
    ->hasRequirement('_cart_api')
    ->willReturn(TRUE);
  $mocked_route_match
    ->getRouteObject()
    ->willReturn($mocked_route
    ->reveal());
  $container
    ->set('current_route_match', $mocked_route_match
    ->reveal());
}