diff --git a/src/Tests/ParagraphsAdministrationTest.php b/src/Tests/ParagraphsAdministrationTest.php index ba75344..7476b91 100644 --- a/src/Tests/ParagraphsAdministrationTest.php +++ b/src/Tests/ParagraphsAdministrationTest.php @@ -33,6 +33,8 @@ class ParagraphsAdministrationTest extends WebTestBase { 'field_ui', 'entity_reference', 'block', + 'diff', + 'diff_test', ); /** @@ -65,7 +67,8 @@ class ParagraphsAdministrationTest extends WebTestBase { 'administer paragraph form display', 'administer node form display', 'edit any article content', - 'delete any article content' + 'view article revisions', + 'delete any article content', )); $this->drupalLogin($admin_user); @@ -186,6 +189,78 @@ class ParagraphsAdministrationTest extends WebTestBase { // // Make sure two paragraph entities have been deleted. // $current_paragraphs = Paragraph::loadMultiple(); // $this->assertTrue(empty($current_paragraphs)); + + $this->drupalGet('admin/config/content/diff/fields'); + + $edit = array( + 'fields[entity_reference_revisions][plugin][type]' => 'entity_reference_revisions_field_diff_builder', + ); + + $this->drupalPostForm(NULL, $edit, t('Save')); + + $this->drupalGet('node/add/article'); + + $title = $this->randomMachineName(); + + $this->drupalPostForm(NULL, NULL, t('Add Text + Image')); + $this->drupalPostForm(NULL, NULL, t('Add Text + Image')); + + $edit = array( + 'title[0][value]' => $title, + 'field_paragraphs[0][subform][field_text][0][value]' => 'Test text 1', + 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', + ); + $this->drupalPostForm(NULL, $edit, t('Save and publish')); + + $node = $this->drupalGetNodeByTitle($title); + $this->drupalGet('node/' . $node->id()); + + // Create a second revision, with a comment. + $edit = array( + 'body[0][value]' => '

Revision 2

', + 'revision' => TRUE, + 'field_paragraphs[1][subform][field_text][0][value]' => 'New paragraph text', + 'revision_log[0][value]' => 'Revision 2 comment', + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalGet('node/' . $node->id()); + + // Check the revisions overview for second revision. + $this->clickLink(t('Revisions')); + $rows = $this->xpath('//tbody/tr'); + // Make sure only two revisions available. + $this->assertEqual(count($rows), 2); + + // Compare the revisions in standard mode. + $this->drupalPostForm(NULL, NULL, t('Compare')); + + // Ccheck, if the second paragraph is changed. + $this->assertText('Changes to Paragraphs'); + $this->assertText('New paragraph text'); + $this->assertRaw('New paragraph '); + + $this->drupalGet('node/' . $node->id()); + + $new_revision = array( + 'body[0][value]' => '

Revision 3

', + 'revision' => TRUE, + 'field_paragraphs[1][subform][field_text][0][value]' => 'New paragraph text for testing', + 'revision_log[0][value]' => 'Revision 3 comment', + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $new_revision, t('Save and keep published')); + $this->drupalGet('node/' . $node->id()); + + // Check the revisions overview for third revision. + $this->clickLink(t('Revisions')); + + // Compare the revisions in standard mode. + $this->drupalPostForm(NULL, NULL, t('Compare')); + + // Ccheck, if the second paragraph is changed. + $this->assertText('Changes to Paragraphs'); + $this->assertText('New paragraph text for testing'); + $this->assertRaw('for testing'); + } }