public function CourierGlobalCollectionTest::testGlobalTemplateCollectionLiveImportTemplate in Courier 2.x
Same name and namespace in other branches
- 8 tests/src/Kernel/CourierGlobalCollectionTest.php \Drupal\Tests\courier\Kernel\CourierGlobalCollectionTest::testGlobalTemplateCollectionLiveImportTemplate()
Ensure active config is loaded into template entity.
File
- tests/
src/ Kernel/ CourierGlobalCollectionTest.php, line 78
Class
- CourierGlobalCollectionTest
- Tests Courier global template collections interaction with local templates.
Namespace
Drupal\Tests\courier\KernelCode
public function testGlobalTemplateCollectionLiveImportTemplate() {
$old_message = $this
->randomString();
$gtc = GlobalTemplateCollection::create([
'id' => $this
->randomMachineName(),
])
->setTemplate('courier_test_message', [
'message' => $old_message,
]);
$gtc
->save();
// Instantiate template collection.
$tc = $this->gtcService
->getLocalCollection($gtc);
$template_id = $tc
->getTemplate('courier_test_message')
->id();
$new_message = $this
->randomString();
$gtc
->setTemplate('courier_test_message', [
'message' => $new_message,
])
->save();
// Reset entity cache so hook_entity_load is triggered again.
\Drupal::entityTypeManager()
->getStorage('courier_test_message')
->resetCache();
$template = TestMessage::load($template_id);
$this
->assertEquals($new_message, $template
->getMessage());
}