public function ParagraphsLibraryTest::testLibraryitemValidation in Paragraphs 8
Tests the library item validation.
File
- modules/
paragraphs_library/ tests/ src/ Functional/ ParagraphsLibraryTest.php, line 497
Class
- ParagraphsLibraryTest
- Tests paragraphs library functionality.
Namespace
Drupal\Tests\paragraphs_library\FunctionalCode
public function testLibraryitemValidation() {
$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_paragraph';
$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');
// Check the label validation.
$this
->submitForm([], 'Save');
$this
->assertSession()
->pageTextContains('Label field is required.');
$edit = [
'label[0][value]' => 're usable paragraph label',
];
$this
->submitForm($edit, 'Save');
// Check the paragraph validation.
$this
->assertSession()
->pageTextContains('Paragraphs field is required.');
$this
->submitForm([], 'paragraphs_text_paragraph_add_more');
$edit['paragraphs[0][subform][field_text][0][value]'] = 're_usable_text';
// Check that the library item is created.
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Paragraph re usable paragraph label has been created.');
$this
->clickLink('Edit');
$edit = [
'paragraphs[0][subform][field_text][0][value]' => 'new text',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Paragraph re usable paragraph label has been updated.');
}