You are here

protected function DiffLocaleTest::doTestUndefinedTranslationFilter in Diff 8

Tests the undefined translation filtering when navigating trough revisions.

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

File

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

Class

DiffLocaleTest
Test diff functionality with localization and translation.

Namespace

Drupal\Tests\diff\FunctionalJavascript

Code

protected function doTestUndefinedTranslationFilter() {

  // Create a node in with undefined langcode.
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'title' => 'undefined_language_revision_0',
    'langcode' => 'und',
  ]);
  $revision1 = $node
    ->getRevisionId();

  // Create 3 new revisions of the node.
  $node
    ->setTitle('undefined_language_revision_1');
  $node
    ->setNewRevision(TRUE);
  $node
    ->save();
  $revision2 = $node
    ->getRevisionId();
  $node
    ->setTitle('undefined_language_revision_2');
  $node
    ->setNewRevision(TRUE);
  $node
    ->save();
  $node
    ->setTitle('undefined_language_revision_3');
  $node
    ->setNewRevision(TRUE);
  $node
    ->save();

  // Check the amount of revisions displayed.
  $this
    ->drupalGet('node/' . $node
    ->id() . '/revisions');
  $element = $this
    ->getSession()
    ->getPage()
    ->findAll('xpath', '//*[@id="edit-node-revisions-table"]/tbody/tr');
  $this
    ->assertEqual(count($element), 4);

  // Compare the first two revisions.
  $this
    ->drupalGet('node/' . $node
    ->id() . '/revisions/view/' . $revision1 . '/' . $revision2 . '/split_fields');
  $diffs = $this
    ->getSession()
    ->getPage()
    ->findAll('xpath', '//span[@class="diffchange"]');
  $this
    ->assertEqual($diffs[0]
    ->getText(), 'undefined_language_revision_0');
  $this
    ->assertEqual($diffs[1]
    ->getText(), 'undefined_language_revision_1');

  // Compare the next two revisions.
  $this
    ->clickLink('Next change');
  $diffs = $this
    ->getSession()
    ->getPage()
    ->findAll('xpath', '//span[@class="diffchange"]');
  $this
    ->assertEqual($diffs[0]
    ->getText(), 'undefined_language_revision_1');
  $this
    ->assertEqual($diffs[1]
    ->getText(), 'undefined_language_revision_2');
}