Tests converting Library item into a paragraph.
public function testConvertLibraryItemIntoParagraph() {
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
'administer paragraphs library',
]);
// Add a Paragraph type with a text field.
$paragraph_type = 'text';
$this
->addParagraphsType($paragraph_type);
static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
// Add a new library item.
$this
->drupalGet('admin/content/paragraphs');
$this
->clickLink('Add library item');
$this
->submitForm([], 'paragraphs_text_add_more');
$edit = [
'label[0][value]' => 'reusable paragraph label',
'paragraphs[0][subform][field_text][0][value]' => 'reusable_text',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Paragraph reusable paragraph label has been created.');
// Add created library item to a node.
$this
->drupalGet('node/add/paragraphed_test');
$this
->submitForm([], 'field_paragraphs_from_library_add_more');
$edit = [
'title[0][value]' => 'Node with converted library item',
'field_paragraphs[0][subform][field_reusable_paragraph][0][target_id]' => 'reusable paragraph label',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('paragraphed_test Node with converted library item has been created.');
$this
->assertSession()
->pageTextContains('reusable_text');
// Convert library item to paragraph.
$this
->clickLink('Edit');
$this
->submitForm([], 'field_paragraphs_0_unlink_from_library');
$this
->assertSession()
->fieldExists('field_paragraphs[0][subform][field_text][0][value]');
$this
->assertSession()
->fieldNotExists('field_paragraphs[0][subform][field_reusable_paragraph][0][target_id]');
$this
->assertSession()
->pageTextContains('reusable_text');
$this
->submitForm([], 'Save');
$this
->assertSession()
->pageTextContains('reusable_text');
}