You are here

public function ModuleIntegrationTest::testDiffModule in Thunder 6.1.x

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  2. 8.2 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  3. 8.3 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  4. 8.4 tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  5. 6.2.x tests/src/FunctionalJavascript/ModuleIntegrationTest.php \Drupal\Tests\thunder\FunctionalJavascript\ModuleIntegrationTest::testDiffModule()
  6. 6.0.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() {
  $node = $this
    ->loadNodeByUuid('36b2e2b2-3df0-43eb-a282-d792b0999c07');
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));

  /** @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');
  $media1 = $this
    ->loadMediaByUuid('17965877-27b2-428f-8b8c-7dccba9786e5');
  $this
    ->selectMedia('field_teaser_media', 'image_browser', [
    'media:' . $media1
      ->id(),
  ]);
  $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);
  $media2 = $this
    ->loadMediaByUuid('5d719c64-7f32-4062-9967-9874f5ca3eba');
  $this
    ->addImageParagraph('field_paragraphs', [
    'media:' . $media2
      ->id(),
  ]);
  $this
    ->clickSave();
  $this
    ->drupalGet($node
    ->toUrl('version-history'));
  $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',
  ], []);
}