You are here

public function FeedsEventsTest::testEventDispatchOrderOnClear in Feeds 8.3

Tests the order in which events are dispatched when clearing items.

File

tests/src/Kernel/FeedsEventsTest.php, line 220

Class

FeedsEventsTest
Tests for dispatching feeds events.

Namespace

Drupal\Tests\feeds\Kernel

Code

public function testEventDispatchOrderOnClear() {

  // Import items first.
  $feed_type = $this
    ->createFeedTypeForCsv([
    'guid' => 'guid',
    'title' => 'title',
  ]);
  $feed = $this
    ->createFeed($feed_type
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/csv/content.csv',
  ]);
  $feed
    ->import();

  // Now delete all items using a batch.
  $GLOBALS['feeds_test_events'] = [];
  $feed
    ->startBatchClear();
  $batch =& batch_get();
  $batch['progressive'] = FALSE;
  batch_process();
  $this
    ->assertEventSubscriberMessageOrder([
    FeedsSubscriber::class . '::onInitClear called',
    FeedsSubscriber::class . '::onClear called',
  ]);
}