public function MessageEntityDelete::setUp in Message 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ MessageEntityDelete.php, line 48
Class
- MessageEntityDelete
- Test the Message delete on entity delete functionality.
Namespace
Drupal\Tests\message\FunctionalCode
public function setUp() {
parent::setUp();
// Set config.
$entities = [
'node',
'taxonomy_term',
'user',
];
$this
->configSet('delete_on_entity_delete', $entities);
// Set config.
$this
->createMessageTemplate('dummy_message', 'Dummy message', 'This is a dummy message text', [
'Dummy message template.',
]);
// Create a vocabulary.
$this->vocabulary = Vocabulary::create([
'name' => $this
->randomMachineName(),
'description' => $this
->randomMachineName(),
'vid' => mb_strtolower($this
->randomMachineName()),
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'weight' => mt_rand(0, 10),
]);
$this->vocabulary
->save();
$this
->createTermReferenceField(TRUE, 'field_term_references');
$this
->createEntityReferenceField(TRUE, 'field_node_references');
$this
->createTermReferenceField(FALSE, 'field_term_reference');
$this
->createEntityReferenceField(FALSE, 'field_node_reference');
$this
->createEntityReferenceField(FALSE, 'field_user_reference', 'user');
$this->nodeType = $this
->drupalCreateContentType();
for ($i = 0; $i <= 6; $i++) {
$this->container
->get('entity_type.manager')
->getStorage('node')
->create([
'type' => $this->nodeType
->id(),
'title' => 'Node ' . $i,
])
->save();
$this->container
->get('entity_type.manager')
->getStorage('taxonomy_term')
->create([
'vid' => $this->vocabulary
->id(),
'name' => 'term ' . $i,
])
->save();
}
}