public function ParagraphsCollectionDemoTest::testParagraphTypes in Paragraphs Collection 8
Tests paragraph types.
File
- modules/
paragraphs_collection_demo/ tests/ src/ Functional/ ParagraphsCollectionDemoTest.php, line 154
Class
- ParagraphsCollectionDemoTest
- Test the demo for Paragraphs Collection.
Namespace
Drupal\Tests\paragraphs_collection_demo\FunctionalCode
public function testParagraphTypes() {
$this
->addParagraphedContentType('paragraphed_test');
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
'administer paragraphs library',
]);
$this
->drupalGet('/node/add/paragraphed_test');
$this
->drupalPostForm(NULL, [], 'field_paragraphs_image_add_more');
$this
->drupalPostForm(NULL, [], 'field_paragraphs_image_text_add_more');
$image = current($this
->getTestFiles('image'));
$file_system = \Drupal::service('file_system');
$edit = [
'title[0][value]' => 'Paragraph types example',
'files[field_paragraphs_0_subform_paragraphs_image_0]' => $file_system
->realpath($image->uri),
'field_paragraphs[1][subform][paragraphs_text][0][value]' => 'Text test with image',
'files[field_paragraphs_1_subform_paragraphs_image_0]' => $file_system
->realpath($image->uri),
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// Asserts the text and image type.
$this
->assertSession()
->pageTextContains('Text test with image');
$this
->assertRaw($image->filename);
}