You are here

public function ModuleIntegrationTest::testDiffModule in Thunder 8.5

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  2. 8.3 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  3. 8.4 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  4. 6.2.x tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  5. 6.0.x tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  6. 6.1.x tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()

Testing integration of "diff" module.

File

tests/src/FunctionalJavascript/ModuleIntegrationTest.php, line 107

Class

ModuleIntegrationTest
Testing of module integrations.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testDiffModule() {
  $this
    ->drupalGet('node/7/edit');

  /** @var \Behat\Mink\Element\DocumentElement $page */
  $page = $this
    ->getSession()
    ->getPage();
  $teaserField = $page
    ->find('xpath', '//*[@data-drupal-selector="edit-field-teaser-text-0-value"]');
  $initialTeaserText = $teaserField
    ->getValue();
  $teaserText = 'Start with Text. ' . $initialTeaserText . ' End with Text.';
  $teaserField
    ->setValue($teaserText);
  $this
    ->clickButtonDrupalSelector($page, 'edit-field-teaser-media-current-items-0-remove-button');
  $this
    ->selectMedia('field_teaser_media', 'image_browser', [
    'media:1',
  ]);
  $newParagraphText = 'One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them!';
  $this
    ->addTextParagraph('field_paragraphs', $newParagraphText);
  $this
    ->addImageParagraph('field_paragraphs', [
    'media:5',
  ]);
  $this
    ->clickSave();
  $this
    ->drupalGet('node/7/revisions');
  $firstRightRadio = $page
    ->find('xpath', '//table[contains(@class, "diff-revisions")]/tbody//tr[1]//input[@name="radios_right"]');
  $firstRightRadio
    ->click();
  $lastLeftRadio = $page
    ->find('xpath', '//table[contains(@class, "diff-revisions")]/tbody//tr[last()]//input[@name="radios_left"]');
  $lastLeftRadio
    ->click();

  // Open diff page.
  $page
    ->find('xpath', '//*[@data-drupal-selector="edit-submit"]')
    ->click();

  // Validate that diff is correct.
  $this
    ->validateDiff('Teaser Text', [
    '1' => $initialTeaserText,
  ], [], [
    '1' => $teaserText,
  ], [
    '1' => [
      'Start with Text.',
      '. End with Text',
    ],
  ]);
  $this
    ->validateDiff('Teaser Media', [
    '1' => 'DrupalCon Logo',
  ], [
    '1' => [
      'DrupalCon Logo',
    ],
  ], [
    '1' => 'Thunder',
  ], [
    '1' => [
      'Thunder',
    ],
  ]);
  $this
    ->validateDiff('Paragraphs > Text', [
    '1' => '',
  ], [], [
    '1' => '<p>' . $newParagraphText . '</p>',
    '2' => '',
  ], []);
  $this
    ->validateDiff('Paragraphs > Image', [
    '1' => '',
  ], [], [
    '1' => 'Thunder City',
  ], []);
}