Skip to content
Snippets Groups Projects
Unverified Commit f7c9202b authored by Alex Pott's avatar Alex Pott
Browse files

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

(cherry picked from commit 4f043a2e)
parent 834c16c5
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ public function doUpgradeAndIncremental() {
// Test the review form.
$this->assertReviewForm();
$this->useTestMailCollector();
$this->submitForm([], 'Perform upgrade');
$this->assertUpgrade($this->getEntityCounts());
......@@ -57,4 +58,16 @@ public function doUpgradeAndIncremental() {
$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);
}
}
......@@ -357,4 +357,14 @@ protected function assertFileMigrations() {
}
}
/**
* 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']);
}
}
......@@ -206,6 +206,8 @@ public function testUpgradeAndIncremental() {
$this->assertUserLogIn(2, 'john.doe_pass');
$this->assertFollowUpMigrationResults();
$this->assertEmailsSent();
}
/**
......
......@@ -61,6 +61,7 @@ public function testMigrateUpgradeExecute() {
$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.
......
......@@ -230,6 +230,8 @@ public function testUpgradeAndIncremental() {
$this->assertUserLogIn(2, 'a password');
$this->assertFollowUpMigrationResults();
$this->assertEmailsSent();
}
/**
......
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