Unverified Commit ee025067 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 47d0aa0e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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);
  }

}
+10 −0
Original line number Diff line number Diff line
@@ -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']);
  }

}
+2 −0
Original line number Diff line number Diff line
@@ -206,6 +206,8 @@ public function testUpgradeAndIncremental() {
    $this->assertUserLogIn(2, 'john.doe_pass');

    $this->assertFollowUpMigrationResults();

    $this->assertEmailsSent();
  }

  /**
+1 −0
Original line number Diff line number Diff line
@@ -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.
+2 −0
Original line number Diff line number Diff line
@@ -230,6 +230,8 @@ public function testUpgradeAndIncremental() {
    $this->assertUserLogIn(2, 'a password');

    $this->assertFollowUpMigrationResults();

    $this->assertEmailsSent();
  }

  /**