You are here

public function CourierGlobalCollectionTest::testCreateTemplateCollection in Courier 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/CourierGlobalCollectionTest.php \Drupal\Tests\courier\Kernel\CourierGlobalCollectionTest::testCreateTemplateCollection()

Baseline functionality.

Ensure referencing a global template collection will automatically create a template collection.

File

tests/src/Kernel/CourierGlobalCollectionTest.php, line 41

Class

CourierGlobalCollectionTest
Tests Courier global template collections interaction with local templates.

Namespace

Drupal\Tests\courier\Kernel

Code

public function testCreateTemplateCollection() {
  $content = $this
    ->randomString();
  $gtc = GlobalTemplateCollection::create([
    'id' => $this
      ->randomMachineName(),
  ])
    ->setTemplate('courier_test_message', [
    'message' => $content,
  ]);
  $gtc
    ->save();
  $tc = $this->gtcService
    ->getLocalCollection($gtc);
  $this
    ->assertTrue($tc instanceof TemplateCollectionInterface);
  $this
    ->assertEquals(2, count($tc
    ->getTemplates()), 'Templates for courier_email and courier_test_message.');
  $this
    ->assertEquals($content, $tc
    ->getTemplate('courier_test_message')
    ->getMessage());
}