Skip to content
Snippets Groups Projects
Verified Commit a9046450 authored by Dave Long's avatar Dave Long
Browse files

Issue #3082211 by quietone, Pooja Ganjage, smustgrave, danflanagan8, Spokje,...

Issue #3082211 by quietone, Pooja Ganjage, smustgrave, danflanagan8, Spokje, benjifisher, mikelutz, Wim Leers: Migrate UI upgrade tests should provide the complete log
parent 5a571f6f
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\migrate_drupal_ui\Functional;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
/**
......@@ -12,6 +13,27 @@ abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase {
use CreateTestContentEntitiesTrait;
/**
* Indicates if the watchdog logs should be output.
*
* @var bool
*/
protected bool $outputLogs = FALSE;
/**
* The admin username after the migration.
*
* @var string
*/
protected string $migratedAdminUserName = 'admin';
/**
* The number of expected logged errors of type migrate_drupal_ui.
*
* @var int
*/
protected int $expectedLoggedErrors = 0;
/**
* {@inheritdoc}
*/
......@@ -23,6 +45,17 @@ protected function setUp(): void {
}
/**
* {@inheritdoc}
*/
protected function tearDown(): void {
if ($this->outputLogs) {
$this->outputLogs($this->migratedAdminUserName);
$this->assertLogError();
}
parent::tearDown();
}
/**
* Executes an upgrade and then an incremental upgrade.
*/
......@@ -108,4 +141,35 @@ protected function assertEntityRevisionsCount(string $content_entity_type_id, in
);
}
/**
* Asserts log errors.
*/
public function assertLogError(): void {
$db = \Drupal::service('database');
$num_errors = $db->select('watchdog', 'w')
->fields('w')
->condition('type', 'migrate_drupal_ui')
->condition('severity', RfcLogLevel::ERROR)
->countQuery()
->execute()
->fetchField();
$this->assertSame($this->expectedLoggedErrors, (int) $num_errors);
}
/**
* Preserve the logs pages.
*/
public function outputLogs(string $username): void {
// Ensure user 1 is accessing the admin log. Change the username because
// the migration changes the username of user 1 but not the password.
if (\Drupal::currentUser()->id() != 1) {
$this->rootUser->name = $username;
$this->drupalLogin($this->rootUser);
}
$this->drupalGet('/admin/reports/dblog');
while ($next_link = $this->getSession()->getPage()->findLink('Next page')) {
$next_link->click();
}
}
}
......@@ -51,6 +51,11 @@ protected function setUp(): void {
$this->nodeStorage->delete($this->nodeStorage->loadMultiple());
$this->loadFixture($this->getModulePath('migrate_drupal') . '/tests/fixtures/drupal6.php');
// Enable saving the logs and set the post migration admin user name.
$this->outputLogs = TRUE;
$this->migratedAdminUserName = 'root';
$this->expectedLoggedErrors = 39;
}
/**
......
......@@ -54,6 +54,11 @@ protected function setUp(): void {
$this->nodeStorage->delete($this->nodeStorage->loadMultiple());
$this->loadFixture($this->getModulePath('migrate_drupal') . '/tests/fixtures/drupal7.php');
// Enable saving the logs and set the post migration admin user name.
$this->outputLogs = TRUE;
$this->migratedAdminUserName = 'admin';
$this->expectedLoggedErrors = 27;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment