You are here

public function DigestActionsTest::setUp in Message Digest 8

Overrides MessageSubscribeEmailTestBase::setUp

File

message_digest_ui/tests/src/Kernel/DigestActionsTest.php, line 52

Class

DigestActionsTest
Test message digest actions.

Namespace

Drupal\Tests\message_digest_ui\Kernel

Code

public function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('taxonomy_term');
  $this
    ->installConfig([
    'message_digest',
  ]);

  // Clear out the cached definitions since message digest needs to provide
  // its config-based ones.
  $this->container
    ->get('plugin.message_notify.notifier.manager')
    ->clearCachedDefinitions();
  $this->actionManager = $this->container
    ->get('plugin.manager.action');
  $this->actionStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('action');

  // Install the module here, otherwise message_digest attempts to install
  // message_digest_ui config.
  $this->container
    ->get('module_installer')
    ->install([
    'message_digest_ui',
  ]);
  $this->actionManager
    ->clearCachedDefinitions();
  $this
    ->installConfig([
    'message_digest_ui',
  ]);

  // Fake user 2 login.
  $this->container
    ->get('account_switcher')
    ->switchTo($this->users[2]);

  // Verify our flagging field is installed.
  assert($this->container
    ->get('entity_type.manager')
    ->getStorage('field_storage_config')
    ->load('flagging.message_digest'));

  // Add some terms.
  $vocabulary = $this
    ->createVocabulary();
  $this->terms[] = $this
    ->createTerm($vocabulary);
  $this->terms[] = $this
    ->createTerm($vocabulary);
}