X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FTests%2FExperimental%2FParagraphsExperimentalWidgetButtonsTest.php;fp=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FTests%2FExperimental%2FParagraphsExperimentalWidgetButtonsTest.php;h=0000000000000000000000000000000000000000;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=886d7898accb7a4d9489bcfe61045d6a3ff6ac55;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php b/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php deleted file mode 100644 index 886d7898a..000000000 --- a/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php +++ /dev/null @@ -1,187 +0,0 @@ -addParagraphedContentType('paragraphed_test'); - - $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); - // Add a Paragraph type. - $paragraph_type = 'text_paragraph'; - $this->addParagraphsType($paragraph_type); - $this->addParagraphsType('text'); - - // Add a text field to the text_paragraph type. - static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []); - $edit = [ - 'fields[field_paragraphs][type]' => 'paragraphs', - ]; - $this->drupalPostForm('admin/structure/types/manage/paragraphed_test/form-display', $edit, t('Save')); - $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'field_paragraphs_text_paragraph_add_more'); - - // Create a node with a Paragraph. - $text = 'recognizable_text'; - $edit = [ - 'title[0][value]' => 'paragraphs_mode_test', - 'field_paragraphs[0][subform][field_text][0][value]' => $text, - ]; - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_text_paragraph_add_more'); - $this->drupalPostForm(NULL, $edit, t('Save')); - $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); - - // Test the 'Open' edit mode. - $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $text); - $this->drupalPostForm(NULL, [], t('Save')); - $this->assertText($text); - - // Test the 'Closed' edit mode. - $this->setParagraphsWidgetMode('paragraphed_test', 'field_paragraphs', 'closed'); - $this->drupalGet('node/' . $node->id() . '/edit'); - // Click "Edit" button. - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_edit'); - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_1_edit'); - $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $text); - $closed_mode_text = 'closed_mode_text'; - // Click "Collapse" button on both paragraphs. - $edit = ['field_paragraphs[0][subform][field_text][0][value]' => $closed_mode_text]; - $this->drupalPostAjaxForm(NULL, $edit, 'field_paragraphs_0_collapse'); - $edit = ['field_paragraphs[1][subform][field_text][0][value]' => $closed_mode_text]; - $this->drupalPostAjaxForm(NULL, $edit, 'field_paragraphs_1_collapse'); - // Verify that we have warning message for each paragraph. - $this->assertEqual(2, count($this->xpath("//*[contains(@class, 'paragraphs-icon-changed')]"))); - $this->assertRaw('
' . $closed_mode_text); - $this->drupalPostForm(NULL, [], t('Save')); - $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); - $this->assertText($closed_mode_text); - - // Test the 'Preview' closed mode. - $this->setParagraphsWidgetSettings('paragraphed_test', 'field_paragraphs', ['closed_mode' => 'preview']); - $this->drupalGet('node/' . $node->id() . '/edit'); - // Click "Edit" button. - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_edit'); - $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $closed_mode_text); - $preview_mode_text = 'preview_mode_text'; - $edit = ['field_paragraphs[0][subform][field_text][0][value]' => $preview_mode_text]; - // Click "Collapse" button. - $this->drupalPostAjaxForm(NULL, $edit, 'field_paragraphs_0_collapse'); - $this->assertText('You have unsaved changes on this Paragraph item.'); - $this->assertEqual(1, count($this->xpath("//*[contains(@class, 'paragraphs-icon-changed')]"))); - $this->assertText($preview_mode_text); - $this->drupalPostForm(NULL, [], t('Save')); - $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); - $this->assertText($preview_mode_text); - - // Test the remove function. - $this->drupalGet('node/' . $node->id() . '/edit'); - // Click "Remove" button. - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove'); - $this->drupalPostForm(NULL, [], t('Save')); - $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); - $this->assertNoText($preview_mode_text); - } - - /** - * Tests if buttons are present for each widget mode. - */ - public function testButtonsVisibility() { - $this->addParagraphedContentType('paragraphed_test'); - - $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); - // Add a Paragraph type. - $paragraph_type = 'text_paragraph'; - $this->addParagraphsType($paragraph_type); - $this->addParagraphsType('text'); - - // Add a text field to the text_paragraph type. - static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []); - $edit = [ - 'fields[field_paragraphs][type]' => 'paragraphs', - ]; - $this->drupalPostForm('admin/structure/types/manage/paragraphed_test/form-display', $edit, t('Save')); - $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'field_paragraphs_text_paragraph_add_more'); - - // Create a node with a Paragraph. - $text = 'recognizable_text'; - $edit = [ - 'title[0][value]' => 'paragraphs_mode_test', - 'field_paragraphs[0][subform][field_text][0][value]' => $text, - ]; - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_text_paragraph_add_more'); - $this->drupalPostForm(NULL, $edit, t('Save')); - $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); - - // Checking visible buttons on "Open" mode. - $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertField('field_paragraphs_0_collapse'); - $this->assertField('field_paragraphs_0_remove'); - $this->assertField('field_paragraphs_0_duplicate'); - - // Checking visible buttons on "Closed" mode. - $this->setParagraphsWidgetMode('paragraphed_test', 'field_paragraphs', 'closed'); - $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertField('field_paragraphs_0_edit'); - $this->assertField('field_paragraphs_0_remove'); - $this->assertField('field_paragraphs_0_duplicate'); - - // Checking visible buttons on "Preview" mode. - $this->setParagraphsWidgetMode('paragraphed_test', 'field_paragraphs', 'closed'); - $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertField('field_paragraphs_0_edit'); - $this->assertField('field_paragraphs_0_remove'); - $this->assertField('field_paragraphs_0_duplicate'); - - // Checking always show collapse and edit actions. - $this->addParagraphsType('nested_paragraph'); - static::fieldUIAddNewField('admin/structure/paragraphs_type/nested_paragraph', 'nested', 'Nested', 'field_ui:entity_reference_revisions:paragraph', [ - 'settings[target_type]' => 'paragraph', - 'cardinality' => '-1', - ], []); - $this->drupalGet('admin/structure/paragraphs_type/nested_paragraph/form-display'); - $edit = [ - 'fields[field_nested][type]' => 'paragraphs', - ]; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->drupalGet('node/' . $node->id() . '/edit'); - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_nested_paragraph_add_more'); - $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_2_subform_field_nested_nested_paragraph_add_more'); - // Collapse is present on each nesting level. - $this->assertFieldByName('field_paragraphs_2_collapse'); - $this->assertFieldByName('field_paragraphs_2_subform_field_nested_0_collapse'); - - // Tests hook_paragraphs_widget_actions_alter. - $this->drupalGet('node/add/paragraphed_test'); - $this->drupalPostForm(NULL, NULL, t('Add text')); - $this->assertNoField('edit-field-paragraphs-0-top-links-test-button'); - \Drupal::state()->set('paragraphs_test_dropbutton', TRUE); - $this->drupalGet('node/add/paragraphed_test'); - $this->drupalPostForm(NULL, NULL, t('Add text')); - $this->assertNoField('edit-field-paragraphs-0-top-links-test-button'); - } - -}