You are here

CronEventTest.php in Hook Event Dispatcher 3.x

File

modules/core_event_dispatcher/tests/src/Kernel/CronEventTest.php
View source
<?php

namespace Drupal\Tests\core_event_dispatcher\Kernel;

use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\KernelTests\KernelTestBase;

/**
 * @group hook_event_dispatcher
 * @group core_event_dispatcher
 */
class CronEventTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'hook_event_dispatcher',
    'core_event_dispatcher',
  ];

  /**
   * Test the cron event.
   *
   * @throws \Exception
   */
  public function testCronEvent() {
    $called = FALSE;
    $this->container
      ->get('event_dispatcher')
      ->addListener(HookEventDispatcherInterface::CRON, function () use (&$called) {
      $called = TRUE;
    });
    $this->container
      ->get('cron')
      ->run();
    $this
      ->assertTrue($called);
  }

}

Classes

Namesort descending Description
CronEventTest @group hook_event_dispatcher @group core_event_dispatcher