You are here

public function CourierGlobalCollectionTest::testGlobalTemplateCollectionExceptionUnsaved in Courier 8

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

Make sure getting a template collection throws an exception because global template collection is unsaved. Global template collection needs to be saved, and have an ID, to associate in the key/value store.

File

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

Class

CourierGlobalCollectionTest
Tests Courier global template collections interaction with local templates.

Namespace

Drupal\Tests\courier\Kernel

Code

public function testGlobalTemplateCollectionExceptionUnsaved() {
  $gtc = GlobalTemplateCollection::create([
    'id' => $this
      ->randomMachineName(),
  ])
    ->setTemplate('courier_test_message', [
    'message' => $this
      ->randomString(),
  ]);
  $this
    ->setExpectedException('Drupal\\courier\\Exception\\GlobalTemplateCollectionException');
  $this->gtcService
    ->getLocalCollection($gtc);
}