function MigrateMessageControllerTest::testDetail

Same name in this branch
  1. 11.x core/modules/migrate_drupal_ui/tests/src/Functional/MigrateMessageControllerTest.php \Drupal\Tests\migrate_drupal_ui\Functional\MigrateMessageControllerTest::testDetail()
Same name and namespace in other branches
  1. 10 core/modules/migrate/tests/src/Functional/MigrateMessageControllerTest.php \Drupal\Tests\migrate\Functional\MigrateMessageControllerTest::testDetail()
  2. 10 core/modules/migrate_drupal_ui/tests/src/Functional/MigrateMessageControllerTest.php \Drupal\Tests\migrate_drupal_ui\Functional\MigrateMessageControllerTest::testDetail()

Tests the detail pages for migrate messages.

Tests the detail page with the following scenarios;

  • No source database connection or message tables with a valid and an invalid migration.
  • A source database connection with message tables with a valid and an invalid migration.
  • A source database connection with message tables and a source plugin that does not have a description for a source ID in the values returned from fields().

File

core/modules/migrate/tests/src/Functional/MigrateMessageControllerTest.php, line 51

Class

MigrateMessageControllerTest
Tests for the MigrateController class.

Namespace

Drupal\Tests\migrate\Functional

Code

public function testDetail() : void {
    $session = $this->assertSession();
    // Details page with invalid migration.
    $this->drupalGet('/admin/reports/migration-messages/invalid');
    $session->statusCodeEquals(404);
    // Details page with valid migration.
    $this->drupalGet('/admin/reports/migration-messages/custom_test');
    $session->statusCodeEquals(404);
    // Create map and message tables.
    $this->createTables($this->migrationIds);
    $not_available_text = "When there is an error processing a row, the migration system saves the error message but not the source ID(s) of the row. That is why some messages in this table have 'Not available' in the source ID column(s).";
    // Test details page for each migration.
    foreach ($this->migrationIds as $migration_id) {
        $this->drupalGet("/admin/reports/migration-messages/{$migration_id}");
        $session->pageTextContains($migration_id);
        if ($migration_id == 'custom_test') {
            $session->pageTextContains('Not available');
            $session->pageTextContains($not_available_text);
        }
    }
    // Details page with invalid migration.
    $this->drupalGet('/admin/reports/migration-messages/invalid');
    $session->statusCodeEquals(404);
    // Details page for a migration without a map table.
    $this->database
        ->schema()
        ->dropTable('migrate_map_custom_test');
    $this->drupalGet('/admin/reports/migration-messages/custom_test');
    $session->statusCodeEquals(404);
    // Details page for a migration with a map table but no message table.
    $this->createTables($this->migrationIds);
    $this->database
        ->schema()
        ->dropTable('migrate_message_custom_test');
    $this->drupalGet('/admin/reports/migration-messages/custom_test');
    $session->pageTextContains('The message table is missing for this migration.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.