You are here

public function ConfigEntityUpdateTest::testUpdate in Message Digest 8

Test the update hook.

File

tests/src/Functional/Update/ConfigEntityUpdateTest.php, line 30

Class

ConfigEntityUpdateTest
Update hook test for the switch to config entities for intervals.

Namespace

Drupal\Tests\message_digest\Functional\Update

Code

public function testUpdate() {
  $this
    ->runUpdates();

  // Verify that the config entities have been created.
  $entities = \Drupal::entityTypeManager()
    ->getStorage('message_digest_interval')
    ->loadMultiple();
  $this
    ->assertCount(2, $entities);
  $this
    ->assertArrayHasKey('daily', $entities);
  $this
    ->assertArrayHasKey('weekly', $entities);

  /** @var \Drupal\message_notify\Plugin\Notifier\Manager $plugin_manager */
  $plugin_manager = \Drupal::service('plugin.message_notify.notifier.manager');
  $definitions = $plugin_manager
    ->getDefinitions();

  // Verify that the 2 plugins exist.
  $this
    ->assertArrayHasKey('message_digest:daily', $definitions);
  $this
    ->assertArrayHasKey('message_digest:weekly', $definitions);
  $this
    ->assertEquals('1 day', $definitions['message_digest:daily']['digest_interval']);
  $this
    ->assertEquals('1 week', $definitions['message_digest:weekly']['digest_interval']);
}