You are here

public function SpyEventDispatcher::dispatch in Hook Event Dispatcher 8

Mocking an event dispatch, saving the event.

File

tests/src/Unit/Preprocess/Helpers/SpyEventDispatcher.php, line 47

Class

SpyEventDispatcher
Class SpyEventDispatcher.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess\Helpers

Code

public function dispatch($eventName, Event $event = NULL) {
  if (count($this->events) === $this->count) {
    throw new BadMethodCallException("SpyEventDispatcher got called more then {$this->count} time(s)");
  }
  $this->events[$eventName] = $event;
}