public function FeedsEventsTest::testEventDispatchOrderOnImport in Feeds 8.3
Tests the order in which events are dispatched on an import.
File
- tests/
src/ Kernel/ FeedsEventsTest.php, line 136
Class
- FeedsEventsTest
- Tests for dispatching feeds events.
Namespace
Drupal\Tests\feeds\KernelCode
public function testEventDispatchOrderOnImport() {
$GLOBALS['feeds_test_events'] = [];
$feed_type = $this
->createFeedTypeForCsv([
'guid' => 'guid',
'title' => 'title',
]);
// Import feed.
$feed = $this
->createFeed($feed_type
->id(), [
'source' => $this
->resourcesPath() . '/csv/content.csv',
]);
$feed
->import();
$this
->assertEventSubscriberMessageOrder([
// Import starts with fetching.
FeedsSubscriber::class . '::onInitImport called',
FeedsSubscriber::class . '::preFetch called',
FeedsSubscriber::class . '::postFetch called',
// Second stage is parsing.
FeedsSubscriber::class . '::onInitImport called',
FeedsSubscriber::class . '::preParse called',
FeedsSubscriber::class . '::postParse called',
// Third stage is processing, process events occur per item.
FeedsSubscriber::class . '::onInitImport called',
FeedsSubscriber::class . '::preProcess called',
FeedsSubscriber::class . '::prevalidate called',
FeedsSubscriber::class . '::preSave called',
FeedsSubscriber::class . '::postSave called',
FeedsSubscriber::class . '::postProcess called',
// Second item being processed.
FeedsSubscriber::class . '::onInitImport called',
FeedsSubscriber::class . '::preProcess called',
FeedsSubscriber::class . '::prevalidate called',
FeedsSubscriber::class . '::preSave called',
FeedsSubscriber::class . '::postSave called',
FeedsSubscriber::class . '::postProcess called',
// There are no items to clean, so the clean stage is completely skipped.
FeedsSubscriber::class . '::onFinish called',
]);
}