Issue #3207907 by quietone, Berdir, alexpott: Ensure functional tests use the test mail collector

merge-requests/1602/head
Alex Pott 2022-01-03 15:51:23 +00:00
parent 458aa2cb69
commit 4f043a2ecc
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
5 changed files with 28 additions and 0 deletions

View File

@ -36,6 +36,7 @@ abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase {
// Test the review form.
$this->assertReviewForm();
$this->useTestMailCollector();
$this->submitForm([], 'Perform upgrade');
$this->assertUpgrade($this->getEntityCounts());
@ -57,4 +58,16 @@ abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase {
$this->assertUpgrade($this->getEntityCountsIncremental());
}
/**
* Helper to set the test mail collector in settings.php.
*/
public function useTestMailCollector() {
// Set up an override.
$settings['config']['system.mail']['interface']['default'] = (object) [
'value' => 'test_mail_collector',
'required' => TRUE,
];
$this->writeSettings($settings);
}
}

View File

@ -357,4 +357,14 @@ abstract class MigrateUpgradeTestBase extends BrowserTestBase {
}
}
/**
* Confirm emails were sent.
*/
protected function assertEmailsSent() {
// There should be one user activation email.
$captured_emails = \Drupal::state()->get('system.test_mail_collector', []);
$this->assertCount(1, $captured_emails);
$this->assertEquals('user_status_activated', $captured_emails[0]['id']);
}
}

View File

@ -206,6 +206,8 @@ class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
$this->assertUserLogIn(2, 'john.doe_pass');
$this->assertFollowUpMigrationResults();
$this->assertEmailsSent();
}
/**

View File

@ -61,6 +61,7 @@ class DoubleSlashTest extends MigrateUpgradeExecuteTestBase {
$this->submitForm([], 'Continue');
$this->submitForm($edits, 'Review upgrade');
$this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
$this->useTestMailCollector();
$this->submitForm([], 'Perform upgrade');
// Tests the migration log contains an error message.

View File

@ -230,6 +230,8 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
$this->assertUserLogIn(2, 'a password');
$this->assertFollowUpMigrationResults();
$this->assertEmailsSent();
}
/**