You are here

public function MigrateMessageTest::testGetMessages in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php \Drupal\Tests\migrate\Kernel\MigrateMessageTest::testGetMessages()

Tests the return value of getMessages().

This method returns an iterator of StdClass objects. Check that these objects have the expected keys.

File

core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php, line 106

Class

MigrateMessageTest
Tests whether idmap messages are sent to message interface when requested.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testGetMessages() {
  $expected_message = (object) [
    'src_name' => 'source_message',
    'dest_config_name' => NULL,
    'msgid' => '1',
    Sql::SOURCE_IDS_HASH => '170cde81762e22552d1b1578cf3804c89afefe9efbc7cc835185d7141060b032',
    'level' => '1',
    'message' => "'a message' is not an array",
  ];
  $executable = new MigrateExecutable($this->migration, $this);
  $executable
    ->import();
  $count = 0;
  foreach ($this->migration
    ->getIdMap()
    ->getMessages() as $message) {
    ++$count;
    $this
      ->assertEqual($message, $expected_message);
  }
  $this
    ->assertEqual($count, 1);
}