diff --git a/src/Tests/ParagraphsAdministrationTest.php b/src/Tests/ParagraphsAdministrationTest.php index 7476b91..5a6cc3f 100644 --- a/src/Tests/ParagraphsAdministrationTest.php +++ b/src/Tests/ParagraphsAdministrationTest.php @@ -47,12 +47,6 @@ class ParagraphsAdministrationTest extends WebTestBase { $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Place the breadcrumb, tested in fieldUIAddNewField(). $this->drupalPlaceBlock('system_breadcrumb_block'); - } - - /** - * Tests the paragraph creation. - */ - public function testParagraphsCreation() { $admin_user = $this->drupalCreateUser(array( 'administer site configuration', 'administer nodes', @@ -71,6 +65,12 @@ class ParagraphsAdministrationTest extends WebTestBase { 'delete any article content', )); $this->drupalLogin($admin_user); + } + + /** + * Tests the paragraph creation. + */ + public function testParagraphsCreation() { $this->drupalGet('admin/structure/paragraphs_type'); $this->clickLink(t('Add a Paragraphs type')); @@ -190,6 +190,38 @@ class ParagraphsAdministrationTest extends WebTestBase { // $current_paragraphs = Paragraph::loadMultiple(); // $this->assertTrue(empty($current_paragraphs)); + } + + public function testParagraphsDiff() { + + $this->drupalGet('admin/structure/paragraphs_type'); + $this->clickLink(t('Add a Paragraphs type')); + + $edit = array( + 'label' => 'Text only', + 'id' => 'text' + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + // Create field types for text and image. + static::fieldUIAddNewField('admin/structure/paragraphs_type/text', 'text_only', 'Text only', 'text_long', array(), array()); + $this->assertText('Saved Text only configuration.'); + + // Create an article with paragraphs field. + static::fieldUIAddNewField('admin/structure/types/manage/article', 'paragraphs', 'Paragraphs', 'entity_reference_revisions', array( + 'settings[target_type]' => 'paragraph', + 'cardinality' => '-1' + ), array( + 'settings[handler_settings][target_bundles][text]' => TRUE, + )); + // Configure article fields. + $this->drupalGet('admin/structure/types/manage/article/fields'); + $this->clickLink(t('Edit'), 1); + $this->drupalPostForm(NULL, NULL, t('Save settings')); + $this->clickLink(t('Manage display')); + $this->drupalPostForm(NULL, array('fields[field_paragraphs][type]' => 'entity_reference_revisions_entity_view'), t('Save')); + $this->clickLink(t('Manage form display')); + $this->drupalPostForm(NULL, array('fields[field_paragraphs][type]' => 'entity_reference_paragraphs'), t('Save')); + $this->drupalGet('admin/config/content/diff/fields'); $edit = array( @@ -202,13 +234,13 @@ class ParagraphsAdministrationTest extends WebTestBase { $title = $this->randomMachineName(); - $this->drupalPostForm(NULL, NULL, t('Add Text + Image')); - $this->drupalPostForm(NULL, NULL, t('Add Text + Image')); + $this->drupalPostForm(NULL, NULL, t('Add Text only')); + $this->drupalPostForm(NULL, NULL, t('Add Text only')); $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', + 'field_paragraphs[0][subform][field_text_only][0][value]' => 'Test text 1', + 'field_paragraphs[1][subform][field_text_only][0][value]' => 'Test text 2', ); $this->drupalPostForm(NULL, $edit, t('Save and publish')); @@ -219,7 +251,7 @@ class ParagraphsAdministrationTest extends WebTestBase { $edit = array( 'body[0][value]' => '
Revision 2
', 'revision' => TRUE, - 'field_paragraphs[1][subform][field_text][0][value]' => 'New paragraph text', + 'field_paragraphs[1][subform][field_text_only][0][value]' => 'New paragraph text', 'revision_log[0][value]' => 'Revision 2 comment', ); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); @@ -234,7 +266,7 @@ class ParagraphsAdministrationTest extends WebTestBase { // Compare the revisions in standard mode. $this->drupalPostForm(NULL, NULL, t('Compare')); - // Ccheck, if the second paragraph is changed. + // Check, if the second paragraph is changed. $this->assertText('Changes to Paragraphs'); $this->assertText('New paragraph text'); $this->assertRaw('New paragraph '); @@ -244,7 +276,7 @@ class ParagraphsAdministrationTest extends WebTestBase { $new_revision = array( 'body[0][value]' => 'Revision 3
', 'revision' => TRUE, - 'field_paragraphs[1][subform][field_text][0][value]' => 'New paragraph text for testing', + 'field_paragraphs[1][subform][field_text_only][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')); @@ -256,11 +288,10 @@ class ParagraphsAdministrationTest extends WebTestBase { // Compare the revisions in standard mode. $this->drupalPostForm(NULL, NULL, t('Compare')); - // Ccheck, if the second paragraph is changed. + // Check, if the second paragraph is changed. $this->assertText('Changes to Paragraphs'); $this->assertText('New paragraph text for testing'); $this->assertRaw('for testing'); - } }