private function NodeFilterTest::createTestNode in Field Formatter Filter 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/NodeFilterTest.php \Drupal\Tests\field_formatter_filter\Kernel\NodeFilterTest::createTestNode()
Create a node with sample content.
Parameters
string $bundle:
Return value
\Drupal\Core\Entity\EntityInterface
1 call to NodeFilterTest::createTestNode()
- NodeFilterTest::testTeaserFilter in tests/
src/ Kernel/ NodeFilterTest.php - Tests applying the text formatter to node teasers.
File
- tests/
src/ Kernel/ NodeFilterTest.php, line 89
Class
- NodeFilterTest
- Tests applying the filter formatter to a node.
Namespace
Drupal\Tests\field_formatter_filter\KernelCode
private function createTestNode($bundle) {
// Sample markup is in an external file - just to keep HTML out of code.
$path = __DIR__ . '/../..';
$body = file_get_contents($path . '/sample-markup.txt');
$node = Node::create([
'type' => $bundle,
'title' => 'Test this is filtered',
'uid' => 1,
'body' => [
'value' => $body,
'format' => 'full_html',
],
]);
$validated = $node
->validate();
$saved = $node
->save();
// It's now populated with expected values like date and nid, so should be
// ready to render.
return $node;
}