You are here

protected function ConfigDependenciesTest::setUpTemplate in Workbench Email 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/ConfigDependenciesTest.php \Drupal\Tests\workbench_email\Kernel\ConfigDependenciesTest::setUpTemplate()

Creates a test email template.

Parameters

string $id: The id for the template.

Return value

\Drupal\workbench_email\Entity\Template Created template.

1 call to ConfigDependenciesTest::setUpTemplate()
ConfigDependenciesTest::setUp in tests/src/Kernel/ConfigDependenciesTest.php

File

tests/src/Kernel/ConfigDependenciesTest.php, line 106

Class

ConfigDependenciesTest
Defines a class for testing config dependencies.

Namespace

Drupal\Tests\workbench_email\Kernel

Code

protected function setUpTemplate($id = 'test_template') {
  $template = Template::create([
    'id' => $id,
    'label' => ucfirst(str_replace('_', ' ', $id)),
    'recipient_types' => [
      'role' => [
        'id' => 'role',
        'provider' => 'workbench_email',
        'status' => 1,
        'settings' => [
          'roles' => [
            'editor' => 'editor',
          ],
        ],
      ],
      'author' => [
        'id' => 'author',
        'provider' => 'workbench_email',
        'status' => 1,
        'settings' => [],
      ],
      'email' => [
        'id' => 'email',
        'provider' => 'workbench_email',
        'status' => 1,
        'settings' => [
          'fields' => [
            'node:field_email',
          ],
        ],
      ],
    ],
  ]);
  $template
    ->save();
  return $template;
}