$this->loginAsAdmin([
'create paragraphs content',
'administer node display',
'edit any paragraphs content',
$this->loginAsAdmin([
'create paragraphs content',
'administer node display',
'edit any paragraphs content',
'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',
'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',
$node = $this->drupalGetNodeByTitle('TEST TITEL');
$paragraph1 = $node->field_paragraphs[0]->target_id;
$node = $this->drupalGetNodeByTitle('TEST TITEL');
$paragraph1 = $node->field_paragraphs[0]->target_id;
$this->countRevisions($node, $paragraph1, $paragraph2, 1);
$this->countRevisions($node, $paragraph1, $paragraph2, 1);
$this->countRevisions($node, $paragraph1, $paragraph2, 2);
$this->countRevisions($node, $paragraph1, $paragraph2, 2);
$this->loginAsAdmin([
'administer site configuration',
'create article content',
$this->loginAsAdmin([
'administer site configuration',
'create article content',
$this->assertUrl('admin/structure/paragraphs_type/add');
$this->drupalGet('admin/structure/paragraphs_type');
$this->assertUrl('admin/structure/paragraphs_type/add');
$this->drupalGet('admin/structure/paragraphs_type');
// Create paragraph type text + image.
$this->addParagraphsType('text_image');
$this->drupalGet('admin/structure/paragraphs_type/text_image');
// Create paragraph type text + image.
$this->addParagraphsType('text_image');
$this->drupalGet('admin/structure/paragraphs_type/text_image');
'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2',
'files[field_paragraphs_1_subform_field_image_0]' => drupal_realpath('temporary://myImage2.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'),
);
$node = $this->drupalGetNodeByTitle('Test article');
$img1_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage1.jpg'));
$node = $this->drupalGetNodeByTitle('Test article');
$img1_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage1.jpg'));
'field_paragraphs[0][subform][field_image][0][width]' => 300,
'field_paragraphs[0][subform][field_image][0][height]' => 300,
];
'field_paragraphs[0][subform][field_image][0][width]' => 300,
'field_paragraphs[0][subform][field_image][0][height]' => 300,
];
// Assert the paragraph is deleted after the user saves the node.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertNoRaw('<a href="' . $img2_url . '" type="image/jpeg; length=21">myImage2.jpg</a>');
// Assert the paragraph is deleted after the user saves the node.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertNoRaw('<a href="' . $img2_url . '" type="image/jpeg; length=21">myImage2.jpg</a>');
'title[0][value]' => 'Example publish/unpublish',
'field_paragraphs[0][subform][field_text][0][value]' => 'Example published and unpublished',
];
'title[0][value]' => 'Example publish/unpublish',
'field_paragraphs[0][subform][field_text][0][value]' => 'Example published and unpublished',
];
$this->assertText(t('Example published and unpublished'));
$this->clickLink(t('Edit'));
$edit = [
'field_paragraphs[0][subform][status][value]' => FALSE,
];
$this->assertText(t('Example published and unpublished'));
$this->clickLink(t('Edit'));
$edit = [
'field_paragraphs[0][subform][status][value]' => FALSE,
];
'title[0][value]' => 'test required',
'files[field_paragraphs_0_subform_field_paragraphs_0_subform_field_image_only_0]' => drupal_realpath('temporary://myImage2.jpg'),
);
'title[0][value]' => 'test required',
'files[field_paragraphs_0_subform_field_paragraphs_0_subform_field_image_only_0]' => drupal_realpath('temporary://myImage2.jpg'),
);
$edit = [
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][width]' => 100,
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][height]' => 100,
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][alt]' => 'Alternative_text',
];
$edit = [
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][width]' => 100,
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][height]' => 100,
'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][alt]' => 'Alternative_text',
];
$this->assertText('test required has been created.');
$this->assertNoRaw('This value should not be null.');
$this->assertText('test required has been created.');
$this->assertNoRaw('This value should not be null.');
$this->drupalPostForm(NULL, $edit, t('Save and continue'));
$this->assertNoOption('edit-settings-target-type', 'paragraph');
$this->drupalPostForm(NULL, $edit, t('Save and continue'));
$this->assertNoOption('edit-settings-target-type', 'paragraph');
$this->addParagraphsType('nested_double_test');
static::fieldUIAddExistingField('admin/structure/paragraphs_type/nested_double_test', 'field_paragraphs', 'paragraphs_1');
$this->clickLink(t('Manage form display'));
$this->addParagraphsType('nested_double_test');
static::fieldUIAddExistingField('admin/structure/paragraphs_type/nested_double_test', 'field_paragraphs', 'paragraphs_1');
$this->clickLink(t('Manage form display'));
$this->assertText('Nested twins has been created.');
$this->assertNoText('This entity (paragraph: ) cannot be referenced.');
$this->assertText('Nested twins has been created.');
$this->assertNoText('This entity (paragraph: ) cannot be referenced.');
'field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')',
'title[0][value]' => 'choke test',
];
'field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')',
'title[0][value]' => 'choke test',
];
// Restore the Paragraph and fix the broken reference.
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_restore');
$node = $this->drupalGetNodeByTitle('Example publish/unpublish');
// Restore the Paragraph and fix the broken reference.
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_restore');
$node = $this->drupalGetNodeByTitle('Example publish/unpublish');
- $this->drupalPostForm(NULL, ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')'], t('Save and keep published'));
+ $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')'];
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('choke test has been updated.');
$this->assertLink('Example publish/unpublish');
// Delete the new referenced node.
$this->assertText('choke test has been updated.');
$this->assertLink('Example publish/unpublish');
// Delete the new referenced node.
$node = $this->drupalGetNodeByTitle('choke test');
// Attempt to edit the Paragraph.
$this->drupalPostAjaxForm('node/' . $node->id() . '/edit', [], 'field_paragraphs_0_edit');
$node = $this->drupalGetNodeByTitle('choke test');
// Attempt to edit the Paragraph.
$this->drupalPostAjaxForm('node/' . $node->id() . '/edit', [], 'field_paragraphs_0_edit');
- // Try to collapse with an invalid reference.
- $this->drupalPostAjaxForm(NULL, ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => 'foo'], 'field_paragraphs_0_collapse');
+ // Try to save with an invalid reference.
+ $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => 'foo'];
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('There are no entities matching "foo".');
// Remove the Paragraph and save the node.
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove');
$elements = $this->xpath('//*[@name="field_paragraphs_0_confirm_remove"]');
$this->assertTrue(!empty($elements), "'Confirm removal' button appears.");
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_confirm_remove');
$this->assertText('There are no entities matching "foo".');
// Remove the Paragraph and save the node.
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove');
$elements = $this->xpath('//*[@name="field_paragraphs_0_confirm_remove"]');
$this->assertTrue(!empty($elements), "'Confirm removal' button appears.");
$this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_confirm_remove');
$this->assertText('choke test has been updated.');
// Verify that the text displayed is correct when no paragraph has been
$this->assertText('choke test has been updated.');
// Verify that the text displayed is correct when no paragraph has been