You are here

protected function FeedsEventsTest::assertEventSubscriberMessageOrder in Feeds 8.3

Checks the order of event dispatching messages.

Module feeds_test_events implements all feeds events and stores a message for each in $GLOBALS['feeds_test_events'].

Parameters

array $messages: An array of plain-text messages in the order they should appear.

3 calls to FeedsEventsTest::assertEventSubscriberMessageOrder()
FeedsEventsTest::testEventDispatchOrderOnClear in tests/src/Kernel/FeedsEventsTest.php
Tests the order in which events are dispatched when clearing items.
FeedsEventsTest::testEventDispatchOrderOnExpire in tests/src/Kernel/FeedsEventsTest.php
Tests the order in which events are dispatched on an expire.
FeedsEventsTest::testEventDispatchOrderOnImport in tests/src/Kernel/FeedsEventsTest.php
Tests the order in which events are dispatched on an import.

File

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

Class

FeedsEventsTest
Tests for dispatching feeds events.

Namespace

Drupal\Tests\feeds\Kernel

Code

protected function assertEventSubscriberMessageOrder(array $messages) {
  $positions = [];
  foreach ($messages as $message) {

    // Verify that each message is found and record its position.
    $position = array_search($message, $GLOBALS['feeds_test_events']);
    if ($this
      ->assertTrue($position !== FALSE, $message)) {
      $positions[] = $position;
    }
  }

  // Sort the positions and ensure they remain in the same order.
  $sorted = $positions;
  sort($sorted);
  $this
    ->assertTrue($sorted == $positions, 'The event subscriber messages appear in the correct order.');
}