public function ParagraphsLibraryTest::testLibraryItemParagraphsSummary in Paragraphs 8
Tests the library paragraphs summary preview.
File
- modules/
paragraphs_library/ tests/ src/ Functional/ ParagraphsLibraryTest.php, line 454
Class
- ParagraphsLibraryTest
- Tests paragraphs library functionality.
Namespace
Drupal\Tests\paragraphs_library\FunctionalCode
public function testLibraryItemParagraphsSummary() {
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
'administer paragraphs library',
]);
$paragraph_type = 'text';
$this
->addParagraphsType($paragraph_type);
static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
// Create paragraph type Nested test.
$this
->addParagraphsType('nested_test');
static::fieldUIAddNewField('admin/structure/paragraphs_type/nested_test', 'paragraphs', 'Paragraphs', 'entity_reference_revisions', [
'settings[target_type]' => 'paragraph',
'cardinality' => '-1',
], []);
$this
->drupalGet('admin/structure/paragraphs_type/nested_test/form-display');
$edit = [
'fields[field_paragraphs][type]' => 'paragraphs',
];
$this
->submitForm($edit, 'Save');
$this
->drupalGet('admin/content/paragraphs/add/default');
$this
->submitForm([], 'paragraphs_nested_test_add_more');
$this
->submitForm([], 'paragraphs_0_subform_field_paragraphs_text_add_more');
$edit = [
'label[0][value]' => 'Test nested',
'paragraphs[0][subform][field_paragraphs][0][subform][field_text][0][value]' => 'test text paragraph',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('test text paragraph');
// Assert that the user with the access content permission can see the
// paragraph type label.
$user = $this
->drupalCreateUser([
'access content',
'administer paragraphs library',
]);
$this
->drupalLogin($user);
$this
->drupalGet('admin/content/paragraphs');
$paragraph_type = $this
->xpath('//table/tbody/tr/td[2]');
$this
->assertEquals(trim(strip_tags($paragraph_type[0]
->getText())), 'nested_test');
}