You are here

public function LazySubscriberTest::testOnInitClear in Feeds 8.3

@covers ::onInitClear

File

tests/src/Unit/EventSubscriber/LazySubscriberTest.php, line 176

Class

LazySubscriberTest
@coversDefaultClass \Drupal\feeds\EventSubscriber\LazySubscriber @group feeds

Namespace

Drupal\Tests\feeds\Unit\EventSubscriber

Code

public function testOnInitClear() {
  $clearable = $this
    ->createMock('Drupal\\feeds\\Plugin\\Type\\ClearableInterface');
  $clearable
    ->expects($this
    ->exactly(2))
    ->method('clear')
    ->with($this->feed);
  $this->feedType
    ->expects($this
    ->once())
    ->method('getPlugins')
    ->will($this
    ->returnValue([
    $clearable,
    $this->dispatcher,
    $clearable,
  ]));
  $subscriber = new LazySubscriber();
  $subscriber
    ->onInitClear(new InitEvent($this->feed), FeedsEvents::INIT_CLEAR, $this->dispatcher);
  $this->dispatcher
    ->dispatch(FeedsEvents::CLEAR, new ClearEvent($this->feed));

  // Call again.
  $subscriber
    ->onInitClear(new InitEvent($this->feed), FeedsEvents::INIT_CLEAR, $this->explodingDispatcher);
}