You are here

public function MigrateMessageTest::testGetMessages in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php \Drupal\Tests\migrate\Kernel\MigrateMessageTest::testGetMessages()
  2. 10 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
      ->assertEquals($expected_message, $message);
  }
  $this
    ->assertEquals(1, $count);
}