You are here

public function CourierGlobalCollectionInvalidTemplateTest::testInvalidTemplate in Courier 2.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/CourierGlobalCollectionInvalidTemplateTest.php \Drupal\Tests\courier\Kernel\CourierGlobalCollectionInvalidTemplateTest::testInvalidTemplate()

Test that a non-existent template type does not cause problems creating a new template collection.

File

tests/src/Kernel/CourierGlobalCollectionInvalidTemplateTest.php, line 43

Class

CourierGlobalCollectionInvalidTemplateTest
Tests Courier global template collections with invalid template types.

Namespace

Drupal\Tests\courier\Kernel

Code

public function testInvalidTemplate() {
  $gtc = GlobalTemplateCollection::create([
    'id' => 'foobar',
  ])
    ->setTemplate('courier_email', [
    'subject' => 'MySubject22',
    'body' => 'MyBody432423',
  ])
    ->setTemplate($this
    ->randomMachineName(), []);
  $gtc
    ->save();
  $tc = $this->gtcService
    ->getLocalCollection($gtc);
  $this
    ->assertTrue($tc instanceof TemplateCollectionInterface);
  $this
    ->assertEquals(1, count($tc
    ->getTemplates()));
}