public function ClassyParagraphsTest::createNodeWithParagraph in Classy paragraphs 8
Creates a populated node with a text paragraph.
Parameters
$styles:
string $node_type:
Return value
array A node object.
1 call to ClassyParagraphsTest::createNodeWithParagraph()
- ClassyParagraphsTest::testClassyParagraphsCheckSingleStyle in src/
Tests/ ClassyParagraphsTest.php - Test the appearance of a single style.
File
- src/
Tests/ ClassyParagraphsTest.php, line 44
Class
- ClassyParagraphsTest
- Tests the classy_paragraphs_test module.
Namespace
Drupal\classy_paragraphs\TestsCode
public function createNodeWithParagraph($styles, $node_type = 'cp_test') {
$values['type'] = 'cp_test_text';
$values['field_cp_test_body'] = $this
->randomString();
$values['field_cp_test_classes'] = $styles;
$paragraph = Paragraph::create($values);
$paragraph
->save();
$node = Node::create([
'type' => $node_type,
'title' => $this
->randomString(),
'uid' => 0,
'status' => 1,
'field_cp_test_paragraphs' => [
[
'target_id' => $paragraph
->id(),
'target_revision_id' => $paragraph
->getRevisionId(),
],
],
]);
$node
->save();
return [
$node,
];
}