protected function CommentCacheTagsTest::createEntity in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/comment/src/Tests/CommentCacheTagsTest.php \Drupal\comment\Tests\CommentCacheTagsTest::createEntity()
Creates the entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface The entity to be tested.
Overrides EntityCacheTagsTestBase::createEntity
File
- core/
modules/ comment/ src/ Tests/ CommentCacheTagsTest.php, line 59 - Contains \Drupal\comment\Tests\CommentCacheTagsTest.
Class
- CommentCacheTagsTest
- Tests the Comment entity's cache tags.
Namespace
Drupal\comment\TestsCode
protected function createEntity() {
// Create a "bar" bundle for the "entity_test" entity type and create.
$bundle = 'bar';
entity_test_create_bundle($bundle, NULL, 'entity_test');
// Create a comment field on this bundle.
$this
->addDefaultCommentField('entity_test', 'bar', 'comment');
// Display comments in a flat list; threaded comments are not render cached.
$field = FieldConfig::loadByName('entity_test', 'bar', 'comment');
$field
->setSetting('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT);
$field
->save();
// Create a "Camelids" test entity that the comment will be assigned to.
$this->entityTestCamelid = entity_create('entity_test', array(
'name' => 'Camelids',
'type' => 'bar',
));
$this->entityTestCamelid
->save();
// Create a "Llama" comment.
$comment = entity_create('comment', array(
'subject' => 'Llama',
'comment_body' => array(
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
'format' => 'plain_text',
),
'entity_id' => $this->entityTestCamelid
->id(),
'entity_type' => 'entity_test',
'field_name' => 'comment',
'status' => \Drupal\comment\CommentInterface::PUBLISHED,
));
$comment
->save();
return $comment;
}