You are here

public function CasValidatorTest::dispatchEvent in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Service/CasValidatorTest.php \Drupal\Tests\cas\Unit\Service\CasValidatorTest::dispatchEvent()

Dispatch an event.

Parameters

string $event_name: Name of event fired.

\Symfony\Component\EventDispatcher\Event $event: Event fired.

File

tests/src/Unit/Service/CasValidatorTest.php, line 62

Class

CasValidatorTest
CasValidator unit tests.

Namespace

Drupal\Tests\cas\Unit\Service

Code

public function dispatchEvent($event_name, Event $event) {
  $this->events[$event_name] = $event;
  switch ($event_name) {
    case CasHelper::EVENT_PRE_VALIDATE:
      $event
        ->setValidationPath("customPath");
      $event
        ->setParameter("foo", "bar");
      break;
    case CasHelper::EVENT_POST_VALIDATE:
      $propertyBag = $event
        ->getCasPropertyBag();
      $propertyBag
        ->setAttribute('email', [
        'modified@example.com',
      ]);
      break;
  }
}