function MigrateMessageControllerTest::testDetail
Same name in this branch
- 10 core/modules/migrate/tests/src/Functional/MigrateMessageControllerTest.php \Drupal\Tests\migrate\Functional\MigrateMessageControllerTest::testDetail()
Same name in other branches
- 11.x core/modules/migrate/tests/src/Functional/MigrateMessageControllerTest.php \Drupal\Tests\migrate\Functional\MigrateMessageControllerTest::testDetail()
- 11.x 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_drupal_ui/ tests/ src/ Functional/ MigrateMessageControllerTest.php, line 125
Class
- MigrateMessageControllerTest
- Tests for the MigrateController class.
Namespace
Drupal\Tests\migrate_drupal_ui\FunctionalCode
public function testDetail() : void {
$session = $this->assertSession();
// Details page with invalid migration.
$this->drupalGet('/admin/reports/migration-messages/invalid');
$session->statusCodeEquals(404);
$session->pageTextContains('Failed to connect to your database server');
// Details page with valid migration.
$this->drupalGet('/admin/reports/migration-messages/d7_menu');
$session->statusCodeEquals(404);
$session->pageTextNotContains('Failed to connect to your database server');
// Create map and message tables.
$this->createMigrateTables($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 overview without a source database connection and with message
// tables.
$this->drupalGet('/admin/reports/migration-messages');
$session->statusCodeEquals(200);
foreach ($this->migrationIds as $migration_id) {
$session->pageTextContains($migration_id);
}
// Test details page for each migration.
foreach ($this->migrationIds as $migration_id) {
$this->drupalGet("/admin/reports/migration-messages/{$migration_id}");
$session->statusCodeEquals(200);
$session->pageTextNotContains('No database connection configured for source plugin');
$session->pageTextContains($migration_id);
if ($migration_id == 'd7_menu') {
// Confirm the descriptions from fields() are displayed.
$session->pageTextContains('MENU NAME. PRIMARY KEY');
$session->pageTextContains('Not available');
$session->pageTextContains($not_available_text);
}
}
// Create a source database connection.
$this->createMigrationConnection();
$this->sourceDatabase = Database::getConnection('default', 'migrate_drupal_ui');
$this->createSourceTables();
// Now, test with a source database connect and with message tables.
// Details page exists for each migration.
foreach ($this->migrationIds as $migration_id) {
$this->drupalGet("/admin/reports/migration-messages/{$migration_id}");
$session->statusCodeEquals(200);
$session->pageTextNotContains('No database connection configured for source plugin');
$session->pageTextContains($migration_id);
// Confirm the descriptions from fields() are displayed using d7_menu.
if ($migration_id == 'd7_menu') {
$session->pageTextContains('MENU NAME. PRIMARY KEY');
$session->pageTextContains('Not available');
$session->pageTextContains($not_available_text);
}
// Confirm the descriptions from fields() are displayed using
// d7_menu_test, which has a source plugin that is missing the
// 'menu_name' entry in fields().
if ($migration_id == 'd7_menu_test') {
$session->pageTextContains('MENU_NAME');
$session->pageTextContains('Not available');
$session->pageTextContains($not_available_text);
}
}
// Details page for a migration without a map table.
$this->database
->schema()
->dropTable('migrate_map_d7_menu');
$this->drupalGet('/admin/reports/migration-messages/d7_menu');
$session->statusCodeEquals(404);
// Details page for a migration with a map table but no message table.
$this->database
->schema()
->dropTable('migrate_message_d7_menu_links');
$this->drupalGet('/admin/reports/migration-messages/d7_menu_links');
$session->statusCodeEquals(200);
$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.