Loading core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php +64 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -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} */ Loading @@ -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. */ Loading Loading @@ -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(); } } } core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php +5 −0 Original line number Diff line number Diff line Loading @@ -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; } /** Loading core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php +5 −0 Original line number Diff line number Diff line Loading @@ -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; } /** Loading Loading
core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php +64 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -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} */ Loading @@ -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. */ Loading Loading @@ -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(); } } }
core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php +5 −0 Original line number Diff line number Diff line Loading @@ -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; } /** Loading
core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php +5 −0 Original line number Diff line number Diff line Loading @@ -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; } /** Loading