You are here

public function EmailActivationTest::testEmailPluginDisabled in Search API Saved Searches 8

Tests that activation will be skipped if the "E-mail" plugin is disabled.

File

tests/src/Kernel/EmailActivationTest.php, line 305

Class

EmailActivationTest
Tests whether activation mails are sent correctly.

Namespace

Drupal\Tests\search_api_saved_searches\Kernel

Code

public function testEmailPluginDisabled() {
  $type = SavedSearchType::load('default');
  $type
    ->removeNotificationPlugin('email');
  $type
    ->save();

  // Save a new search.
  $search = SavedSearch::create([
    'type' => 'default',
    'label' => 'Test search 1',
  ]);
  $this
    ->assertEquals(SAVED_NEW, $search
    ->save());
  $this
    ->sendMails();

  // Saved search should be active, no mail should have been sent.
  $this
    ->assertTrue($search
    ->get('status')->value);
  $captured_emails = \Drupal::state()
    ->get('system.test_mail_collector');
  $this
    ->assertEmpty($captured_emails);
}