You are here

protected function FreelinkingMultilingualTest::setUp in Freelinking 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/FreelinkingMultilingualTest.php \Drupal\Tests\freelinking\Functional\FreelinkingMultilingualTest::setUp()

Throws

\Drupal\Core\Entity\EntityStorageException

\Behat\Mink\Exception\ExpectationException

Overrides FreelinkingBrowserTestBase::setUp

File

tests/src/Functional/FreelinkingMultilingualTest.php, line 38

Class

FreelinkingMultilingualTest
Tests that multilingual capabilities of Freelinking.

Namespace

Drupal\Tests\freelinking\Functional

Code

protected function setUp() {
  parent::setUp();
  $this
    ->updateFilterSettings();

  // Add a new language.
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Create a user to administer languages.
  $this->adminUser = $this
    ->drupalCreateUser([
    'access administration pages',
    'access content',
    'administer content types',
    'administer filters',
    'administer languages',
    'administer content translation',
    'access user profiles',
    'create page content',
    'create content translations',
    'edit own page content',
    'update content translations',
    'translate any entity',
  ]);
  $this
    ->drupalLogin($this->adminUser);

  // Enable URL and User language detection and selection.
  $edit = [
    'language_interface[enabled][language-url]' => '1',
    'language_interface[enabled][language-user]' => '1',
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));

  // Enable multilingual support for "Basic page" content type.
  $edit = [
    'language_configuration[language_alterable]' => TRUE,
  ];
  $edit = [
    'language_configuration[content_translation]' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->assertSession()
    ->pageTextContains('The content type Basic page has been updated.');

  // Create a node translation.
  $edit = [
    'title[0][value]' => 'Primera página',
    'body[0][value]' => 'Contenido traducido.',
  ];
  $this
    ->drupalPostForm('node/1/translations/add/en/es', $edit, t('Save'));
}