Issue #3207907 by quietone, Berdir, alexpott: Ensure functional tests use the test mail collector
parent
458aa2cb69
commit
4f043a2ecc
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -206,6 +206,8 @@ class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
$this->assertUserLogIn(2, 'john.doe_pass');
|
||||
|
||||
$this->assertFollowUpMigrationResults();
|
||||
|
||||
$this->assertEmailsSent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -230,6 +230,8 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
|
|||
$this->assertUserLogIn(2, 'a password');
|
||||
|
||||
$this->assertFollowUpMigrationResults();
|
||||
|
||||
$this->assertEmailsSent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue