You are here

protected function JsonApiFunctionalMultilingualTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingualTest::setUp()

Overrides JsonApiFunctionalTestBase::setUp

File

core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php, line 39

Class

JsonApiFunctionalMultilingualTest
Tests JSON:API multilingual support.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function setUp() {
  parent::setUp();
  $language = ConfigurableLanguage::createFromLangcode('ca');
  $language
    ->save();
  ConfigurableLanguage::createFromLangcode('ca-fr')
    ->save();

  // In order to reflect the changes for a multilingual site in the container
  // we have to rebuild it.
  $this
    ->rebuildContainer();
  \Drupal::configFactory()
    ->getEditable('language.negotiation')
    ->set('url.prefixes.ca', 'ca')
    ->set('url.prefixes.ca-fr', 'ca-fr')
    ->save();
  ContentLanguageSettings::create([
    'target_entity_type_id' => 'node',
    'target_bundle' => 'article',
  ])
    ->setThirdPartySetting('content_translation', 'enabled', TRUE)
    ->save();
  $this
    ->createDefaultContent(5, 5, TRUE, TRUE, static::IS_MULTILINGUAL, FALSE);
}