You are here

public function CourierGlobalCollectionTest::testGlobalTemplateCollectionExceptionUnsaved in Courier 2.x

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

Test exception.

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 67

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
    ->expectException(GlobalTemplateCollectionException::class);
  $this->gtcService
    ->getLocalCollection($gtc);
}