You are here

public function UnitTest::testAcsfEventPushPop in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 tests/AcsfEventsTest.php \UnitTest::testAcsfEventPushPop()

Tests that the push and pop methods work as expected.

File

tests/AcsfEventsTest.php, line 63
Provides PHPUnit tests for the Acsf Events system.

Class

UnitTest

Code

public function testAcsfEventPushPop() {
  $classes = [
    'UnitTestDummyHandler1',
    'UnitTestDummyHandler2',
    'UnitTestDummyHandler3',
  ];
  $event = new AcsfEvent(new AcsfEventDispatcher(), new AcsfLog(), 'unit_test', [], []);
  foreach ($classes as $class) {
    $event
      ->pushHandler(new $class($event));
  }
  $debug = $event
    ->debug();
  $this
    ->assertCount(3, $debug['handlers']['incomplete']);
  $handlers = [];
  while ($handler = $event
    ->popHandler()) {
    $handlers[] = $handler;
  }
  $this
    ->assertCount(3, $handlers);
  $this
    ->assertEmpty($event
    ->debug());
}