You are here

protected function ProductTranslationTest::setUp in Commerce Core 8.2

Overrides ProductBrowserTestBase::setUp

File

modules/product/tests/src/Functional/ProductTranslationTest.php, line 48

Class

ProductTranslationTest
Tests translating products and variations.

Namespace

Drupal\Tests\commerce_product\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Add the French and German languages.
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->submitForm([
    'predefined_langcode' => 'fr',
  ], t('Add language'));
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->submitForm([
    'predefined_langcode' => 'de',
  ], t('Add language'));

  // Enable content translation on products and variations.
  $this
    ->drupalGet('admin/config/regional/content-language');
  $edit = [
    'entity_types[commerce_product]' => TRUE,
    'settings[commerce_product][default][translatable]' => TRUE,
    'entity_types[commerce_product_variation]' => TRUE,
    'settings[commerce_product_variation][default][translatable]' => TRUE,
  ];
  $this
    ->submitForm($edit, t('Save configuration'));

  // Adding languages requires a container rebuild in the test running
  // environment so that multilingual services are used.
  $this
    ->resetAll();
}