MessageTemplateCrudTest.php in Message 8
File
tests/src/Functional/MessageTemplateCrudTest.php
View source
<?php
namespace Drupal\Tests\message\Functional;
class MessageTemplateCrudTest extends MessageTestBase {
public function testCrudEntityType() {
$created_message_template = $this
->createMessageTemplate('dummy_message', 'Dummy test', 'This is a dummy message with a dummy message', [
'Dummy message',
]);
drupal_static_reset();
$template = $this
->loadMessageTemplate('dummy_message');
$values = [
'template' => 'Template',
'label' => 'Label',
'description' => 'Description',
'text' => 'Text',
];
foreach ($values as $key => $label) {
$this
->assertEquals(call_user_func([
$template,
'get' . $key,
]), call_user_func([
$created_message_template,
'get' . $key,
]), 'The ' . $label . ' between the message we created and loaded were not the same');
}
$template
->setLabel('New label');
$template
->save();
drupal_static_reset();
$template = $this
->loadMessageTemplate('dummy_message');
$this
->assertEqual($template
->getLabel(), 'New label', 'The message was updated successfully');
$template
->delete();
drupal_static_reset();
$this
->assertFalse($this
->loadMessageTemplate('dummy_message'), 'The message was not found in the DB');
}
}