You are here

protected function MessageDigestTrait::assertNotifierViewModes in Message Digest 8

Checks that the given view modes are supported by the given notifier.

Parameters

\Drupal\message_digest\Plugin\Notifier\DigestInterface $notifier: The message digest notifier to check.

array $expected_view_modes: An array of view mode IDs to check.

Throws

\RuntimeException Thrown when one or more of the given view mode IDs are not supported by the given notifier.

2 calls to MessageDigestTrait::assertNotifierViewModes()
MessageDigestSubContext::assertDigestContains in ./message_digest.behat.inc
Checks that the digest for a user contains a certain message.
MessageDigestSubContext::assertDigestNotContains in ./message_digest.behat.inc
Checks that the digest for a user does not contain a certain message.

File

src/Traits/MessageDigestTrait.php, line 124

Class

MessageDigestTrait
Methods useful for testing and integrating the Message Digest module.

Namespace

Drupal\message_digest\Traits

Code

protected function assertNotifierViewModes(DigestInterface $notifier, array $expected_view_modes) {
  $plugin_definition = $notifier
    ->getPluginDefinition();
  $actual_view_modes = array_combine($plugin_definition['viewModes'], $plugin_definition['viewModes']);
  if (!empty($diff = array_diff_key(array_flip($expected_view_modes), $actual_view_modes))) {
    $missing_view_modes = implode(', ', array_keys($diff));
    $id = $notifier
      ->getPluginId();
    throw new \RuntimeException("The following view modes are not supported by the '{$id}' digest notifier: '{$missing_view_modes}'.");
  }
}