You are here

public function CourierGlobalCollectionTest::testCreateTemplateCollection in Courier 2.x

Same name and namespace in other branches
  1. 8 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 47

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());
}