You are here

protected function DiffLocaleTest::doTestTranslationRevisions in Diff 8

Test Diff functionality for the revisions of a translated node.

1 call to DiffLocaleTest::doTestTranslationRevisions()
DiffLocaleTest::testAll in tests/src/FunctionalJavascript/DiffLocaleTest.php
Run all independent tests.

File

tests/src/FunctionalJavascript/DiffLocaleTest.php, line 62

Class

DiffLocaleTest
Test diff functionality with localization and translation.

Namespace

Drupal\Tests\diff\FunctionalJavascript

Code

protected function doTestTranslationRevisions() {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();

  // Create an article and its translation. Assert aliases.
  $edit = array(
    'title[0][value]' => 'English node',
    'langcode[0][value]' => 'en',
  );
  $this
    ->drupalPostNodeForm('node/add/article', $edit, t('Save and publish'));
  $english_node = $this
    ->drupalGetNodeByTitle('English node');
  $this
    ->drupalGet('node/' . $english_node
    ->id() . '/translations');
  $this
    ->clickLink(t('Add'));
  $assert_session
    ->elementExists('css', 'a[href="#edit-revision-information"]')
    ->click();
  $page
    ->fillField('title[0][value]', 'French node');
  $page
    ->uncheckField('revision');
  $this
    ->drupalPostNodeForm(NULL, [], t('Save and keep published (this translation)'));
  $this
    ->rebuildContainer();
  $english_node = $this
    ->drupalGetNodeByTitle('English node');
  $french_node = $english_node
    ->getTranslation('fr');

  // Create a new revision on both languages.
  $edit = array(
    'title[0][value]' => 'Updated title',
    'revision' => TRUE,
  );
  $this
    ->drupalPostNodeForm('node/' . $english_node
    ->id() . '/edit', $edit, t('Save and keep published (this translation)'));
  $edit = array(
    'title[0][value]' => 'Le titre',
    'revision' => TRUE,
  );
  $this
    ->drupalPostNodeForm('fr/node/' . $english_node
    ->id() . '/edit', $edit, t('Save and keep published (this translation)'));

  // View differences between revisions. Check that they don't mix up.
  $this
    ->drupalGet('node/' . $english_node
    ->id() . '/revisions');
  $this
    ->drupalGet('node/' . $english_node
    ->id() . '/revisions/view/1/2/split_fields');
  $assert_session
    ->pageTextContains('Title');
  $assert_session
    ->pageTextContains('English node');
  $assert_session
    ->pageTextContains('Updated title');
  $this
    ->drupalGet('fr/node/' . $english_node
    ->id() . '/revisions');
  $this
    ->drupalGet('fr/node/' . $english_node
    ->id() . '/revisions/view/1/3/split_fields');
  $assert_session
    ->pageTextContains('Title');
  $assert_session
    ->pageTextNotContains('English node');
  $assert_session
    ->pageTextNotContains('Updated title');
  $assert_session
    ->pageTextContains('French node');
  $assert_session
    ->pageTextContains('Le titre');
}