X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FTests%2FExperimental%2FParagraphsExperimentalAdministrationTest.php;fp=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FTests%2FExperimental%2FParagraphsExperimentalAdministrationTest.php;h=0000000000000000000000000000000000000000;hp=e2e309b062caf05ba13d5301390437dc35bac6a2;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php b/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php deleted file mode 100644 index e2e309b06..000000000 --- a/web/modules/contrib/paragraphs/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php +++ /dev/null @@ -1,580 +0,0 @@ -drupalCreateContentType(array('type' => 'paragraphs', 'name' => 'Paragraphs')); - } - - /** - * Tests the revision of paragraphs. - */ - public function testParagraphsRevisions() { - $this->addParagraphedContentType('article', 'paragraphs'); - $this->loginAsAdmin([ - 'create paragraphs content', - 'administer node display', - 'edit any paragraphs content', - 'administer nodes', - ]); - - // Create paragraphs type Headline + Block. - $this->addParagraphsType('text'); - // Create field types for the text. - static::fieldUIAddNewField('admin/structure/paragraphs_type/text', 'text', 'Text', 'text', array(), array()); - $this->assertText('Saved Text configuration.'); - - // Create an article with paragraphs field. - static::fieldUIAddNewField('admin/structure/types/manage/paragraphs', 'paragraphs', 'Paragraphs', 'entity_reference_revisions', array( - 'settings[target_type]' => 'paragraph', - 'cardinality' => '-1', - ), array( - 'settings[handler_settings][target_bundles_drag_drop][text][enabled]' => TRUE, - )); - // Configure article fields. - $this->drupalGet('admin/structure/types/manage/paragraphs/fields'); - $this->clickLink(t('Manage form display')); - $this->drupalPostForm(NULL, array('fields[field_paragraphs][type]' => 'paragraphs'), t('Save')); - - // Create node with our paragraphs. - $this->drupalGet('node/add/paragraphs'); - $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more'); - $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more'); - $edit = [ - 'title[0][value]' => 'TEST TITEL', - '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 + ['status[value]' => TRUE], t('Save')); - - $node = $this->drupalGetNodeByTitle('TEST TITEL'); - $paragraph1 = $node->field_paragraphs[0]->target_id; - $paragraph2 = $node->field_paragraphs[1]->target_id; - - $this->countRevisions($node, $paragraph1, $paragraph2, 1); - - // Edit the node without creating a revision. There should still be only 1 - // revision for nodes and paragraphs. - $edit = [ - 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 1', - 'revision' => FALSE, - ]; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - - $this->countRevisions($node, $paragraph1, $paragraph2, 1); - - // Edit the just created node. Create new revision. Now we should have 2 - // revisions for nodes and paragraphs. - $edit = [ - 'title[0][value]' => 'TEST TITLE', - 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 2', - 'revision' => TRUE, - ]; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - - $this->countRevisions($node, $paragraph1, $paragraph2, 2); - - // Assert the paragraphs have been changed. - $this->assertNoText('Foo Bar 1'); - $this->assertText('Test text 2'); - $this->assertText('Foo Bar 2'); - $this->assertText('TEST TITLE'); - - // Check out the revisions page and assert there are 2 revisions. - $this->drupalGet('node/' . $node->id() . '/revisions'); - $rows = $this->xpath('//tbody/tr'); - // Make sure two revisions available. - $this->assertEqual(count($rows), 2); - // Revert to the old version. - $this->clickLink(t('Revert')); - $this->drupalPostForm(NULL, [], t('Revert')); - $this->drupalGet('node/' . $node->id()); - // Assert the node has been reverted. - $this->assertNoText('Foo Bar 2'); - $this->assertText('Test text 2'); - $this->assertText('Foo Bar 1'); - $this->assertText('TEST TITEL'); - } - - - /** - * Tests the paragraph creation. - */ - public function testParagraphsCreation() { - // Create an article with paragraphs field. - $this->addParagraphedContentType('article'); - $this->loginAsAdmin([ - 'administer site configuration', - 'create article content', - 'create paragraphs content', - 'administer node display', - 'administer paragraph display', - 'edit any article content', - 'delete any article content', - 'access files overview', - ]); - - // Assert suggested 'Add a paragraph type' link when there is no type yet. - $this->drupalGet('admin/structure/paragraphs_type'); - $this->assertText('There is no Paragraphs type yet.'); - $this->drupalGet('admin/structure/types/manage/paragraphs/fields/add-field'); - $edit = [ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', - 'label' => 'Paragraph', - 'field_name' => 'paragraph', - ]; - $this->drupalPostForm(NULL, $edit, 'Save and continue'); - $this->drupalPostForm(NULL, [], 'Save field settings'); - $this->assertLinkByHref('admin/structure/paragraphs_type/add'); - $this->clickLink('here'); - $this->assertUrl('admin/structure/paragraphs_type/add'); - - $this->drupalGet('admin/structure/paragraphs_type'); - $this->clickLink(t('Add paragraph type')); - $this->assertTitle('Add Paragraphs type | Drupal'); - // Create paragraph type text + image. - $this->addParagraphsType('text_image'); - $this->drupalGet('admin/structure/paragraphs_type/text_image'); - $this->assertTitle('Edit text_image paragraph type | Drupal'); - // Create field types for text and image. - static::fieldUIAddNewField('admin/structure/paragraphs_type/text_image', 'text', 'Text', 'text_long', array(), array()); - $this->assertText('Saved Text configuration.'); - static::fieldUIAddNewField('admin/structure/paragraphs_type/text_image', 'image', 'Image', 'image', array(), array('settings[alt_field_required]' => FALSE)); - $this->assertText('Saved Image configuration.'); - - // Create paragraph type Nested test. - $this->addParagraphsType('nested_test'); - - static::fieldUIAddNewField('admin/structure/paragraphs_type/nested_test', 'paragraphs', 'Paragraphs', 'entity_reference_revisions', array( - 'settings[target_type]' => 'paragraph', - 'cardinality' => '-1', - ), array()); - - // Change the add more button to select mode. - $this->clickLink(t('Manage form display')); - $this->drupalPostAjaxForm(NULL, ['fields[field_paragraphs][type]' => 'paragraphs'], 'field_paragraphs_settings_edit'); - $this->drupalPostForm(NULL, ['fields[field_paragraphs][settings_edit_form][settings][add_mode]' => 'select'], t('Update')); - $this->drupalPostForm(NULL, [], t('Save')); - - // Create paragraph type image. - $this->addParagraphsType('image'); - // Create field types for image. - static::fieldUIAddNewField('admin/structure/paragraphs_type/image', 'image_only', 'Image only', 'image', array(), array()); - $this->assertText('Saved Image only configuration.'); - - $this->drupalGet('admin/structure/paragraphs_type'); - $rows = $this->xpath('//tbody/tr'); - // Make sure 2 types are available with their label. - $this->assertEqual(count($rows), 3); - $this->assertText('text_image'); - $this->assertText('image'); - // Make sure there is an edit link for each type. - $this->clickLink(t('Edit')); - // Make sure the field UI appears. - $this->assertLink('Manage fields'); - $this->assertLink('Manage form display'); - $this->assertLink('Manage display'); - $this->assertTitle('Edit image paragraph type | Drupal'); - - // Test for "Add mode" setting. - $this->drupalGet('admin/structure/types/manage/article/form-display'); - $field_name = 'field_paragraphs'; - - // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, ['fields[field_paragraphs][type]' => 'paragraphs'], $field_name . "_settings_edit"); - - // Enable setting. - $edit = array('fields[' . $field_name . '][settings_edit_form][settings][add_mode]' => 'button'); - $this->drupalPostForm(NULL, $edit, t('Save')); - - // Check if the setting is stored. - $this->drupalGet('admin/structure/types/manage/article/form-display'); - $this->assertText('Add mode: Buttons', 'Checking the settings value.'); - - $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit"); - // Assert the 'Buttons' option is selected. - $this->assertOptionSelected('edit-fields-field-paragraphs-settings-edit-form-settings-add-mode', 'button', 'Updated value is correct!.'); - - // Add two Text + Image paragraphs in article. - $this->drupalGet('node/add/article'); - $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_image_add_more'); - $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_image_add_more'); - // Create an 'image' file, upload it. - $text = 'Trust me I\'m an image'; - file_put_contents('temporary://myImage1.jpg', $text); - file_put_contents('temporary://myImage2.jpg', $text); - - $edit = array( - 'title[0][value]' => 'Test article', - 'field_paragraphs[0][subform][field_text][0][value]' => 'Test text 1', - 'files[field_paragraphs_0_subform_field_image_0]' => drupal_realpath('temporary://myImage1.jpg'), - 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', - 'files[field_paragraphs_1_subform_field_image_0]' => drupal_realpath('temporary://myImage2.jpg'), - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - - $node = $this->drupalGetNodeByTitle('Test article'); - $img1_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage1.jpg')); - $img2_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage2.jpg')); - - // Check the text and image after publish. - $this->assertText('Test text 1'); - $this->assertRaw('drupalGet('admin/structure/types/manage/article/form-display'); - // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, array(), "field_paragraphs_settings_edit"); - // Enable setting. - $edit = array('fields[field_paragraphs][settings_edit_form][settings][edit_mode]' => 'closed'); - $this->drupalPostForm(NULL, $edit, t('Save')); - // Check if the setting is stored. - $this->assertText('Edit mode: Closed', 'Checking the settings value.'); - $this->drupalPostAjaxForm(NULL, array(), "field_paragraphs_settings_edit"); - // Assert the 'Closed' option is selected. - $this->assertOptionSelected('edit-fields-field-paragraphs-settings-edit-form-settings-edit-mode', 'closed', 'Updated value correctly.'); - $this->drupalGet('node/1/edit'); - // The textareas for paragraphs should not be visible. - $this->assertNoRaw('field_paragraphs[0][subform][field_text][0][value]'); - $this->assertNoRaw('field_paragraphs[1][subform][field_text][0][value]'); - $this->assertRaw('