You are here

public function AfterParseBaseTest::testDispatch in Feeds 8.3

Tests that the event subscriber is properly called.

@covers ::getSubscribedEvents

File

tests/src/Unit/EventSubscriber/AfterParseBaseTest.php, line 165

Class

AfterParseBaseTest
@coversDefaultClass \Drupal\feeds\EventSubscriber\AfterParseBase @group feeds

Namespace

Drupal\Tests\feeds\Unit\EventSubscriber

Code

public function testDispatch() {

  // Create a few items.
  for ($i = 1; $i <= 3; $i++) {
    $item = new DynamicItem();
    $item
      ->set('id', $i);
    $this->parserResult
      ->addItem($item);
  }
  $this->subscriber
    ->expects($this
    ->exactly(3))
    ->method('alterItem');
  $dispatcher = new EventDispatcher();
  $dispatcher
    ->addSubscriber($this->subscriber);

  // Dispatch the event.
  $dispatcher
    ->dispatch(FeedsEvents::PARSE, $this->event);
}