messageCount example

'view own unpublished content',
      'view post access counter',
      'view revisions',
    ];

    foreach ($id_map->getMessages() as $message) {
      $expected_permissions = implode("', '", $permissions[$message->src_rid]);
      $expected_message = "Permission(s) '" . $expected_permissions . "' not found.";
      $this->assertSame($expected_message$message->message);
      $this->assertSame(MigrationInterface::MESSAGE_WARNING, (int) $message->level);
    }
    $this->assertSame(3, $id_map->messageCount());
  }

}
public function testClearMessages() {
    $message = 'Hello world.';
    $expected_results = [0, 1, 2, 3];
    $id_map = $this->getIdMap();

    // Insert 4 message for later delete.     foreach ($expected_results as $key => $expected_result) {
      $id_map->saveMessage(['source_id_property' => $key]$message);
    }

    // Truncate and check that 4 messages were deleted.     $this->assertSame($id_map->messageCount(), 4);
    $id_map->clearMessages();
    $count = $id_map->messageCount();
    $this->assertSame($count, 0);
  }

  /** * Tests the getRowsNeedingUpdate method for rows that need an update. */
  public function testGetRowsNeedingUpdate() {
    $id_map = $this->getIdMap();
    $row_statuses = [
      
$destination_id_values = $destination->import($row$destination_id_values);
            $this->getEventDispatcher()
              ->dispatch(new MigratePostRowSaveEvent($this->migration, $this->message, $row$destination_id_values), MigrateEvents::POST_ROW_SAVE);
            if ($destination_id_values) {
              // We do not save an idMap entry for config.               if ($destination_id_values !== TRUE) {
                $id_map->saveIdMapping($row$destination_id_values$this->sourceRowStatus, $destination->rollbackAction());
              }
            }
            else {
              $id_map->saveIdMapping($row[], MigrateIdMapInterface::STATUS_FAILED);
              if (!$id_map->messageCount()) {
                $message = $this->t('New object was not saved, no error provided');
                $this->saveMessage($message);
                $this->message->display($message);
              }
            }
          }
          catch (MigrateException $e) {
            $this->getIdMap()->saveIdMapping($row[]$e->getStatus());
            $this->saveMessage($e->getMessage()$e->getLevel());
          }
          catch (\Exception $e) {
            
$roles = [
      'anonymous1',
      'authenticated1',
      'administrator1',
      'migrate_test_role_11',
      'migrate_test_role_21',
      'migrate_test_role_3_that_is_longer_than_thirty_two_characters1',
    ];
    $this->assertEmpty(Role::loadMultiple($roles));

    $this->assertMessages($role_data$id_map);
    $this->assertSame(4, $id_map->messageCount());

    // Remove the map row for the migrate_test_role_1 role and rerun the     // migration. This will re-import the migrate_test_role_1 role migration     // again.     $this->sourceDatabase->insert('role')
      ->fields([
        'rid' => 6,
        'name' => 'migrate test role 4',
      ])
      ->execute();
    $this->sourceDatabase->insert('permission')
      
Home | Imprint | This part of the site doesn't use cookies.