You are here

public function CliCommandsTest::testDeleteSiteAlert in Site Alert 8

Test site alert delete.

@covers ::delete

File

tests/src/Kernel/CliCommandsTest.php, line 154

Class

CliCommandsTest
Tests for the site alert CLI Commands service.

Namespace

Drupal\Tests\site_alert\Kernel

Code

public function testDeleteSiteAlert() : void {

  // Create a simple alert with a message, and a severity.
  $label = 'phpunit_test_delete';
  $message = "A nice bit of message here.";
  $options = [
    'severity' => 'low',
  ];
  $this->cliCommands
    ->create($label, $message, $options);

  // Delete should result in at least one removal.
  $result = $this->cliCommands
    ->delete($label);
  $this
    ->assertGreaterThan(0, $result);

  // If it was deleted, there should be no more found.
  $siteAlerts = $this
    ->loadAlertsByLabel($label);
  $this
    ->assertCount(0, $siteAlerts);
}