public function CliCommandsTest::testDisableAllSiteAlerts in Site Alert 8
Checks that all site alerts can be disabled by passing the 'all' option.
@covers ::disable
File
- tests/
src/ Kernel/ CliCommandsTest.php, line 211
Class
- CliCommandsTest
- Tests for the site alert CLI Commands service.
Namespace
Drupal\Tests\site_alert\KernelCode
public function testDisableAllSiteAlerts() : void {
// Create a range of active and inactive alerts.
$alerts = [
[
'phpunit_test_disable_1',
'An active alert',
[],
],
[
'phpunit_test_disable_2',
'Another active alert',
[],
],
[
'phpunit_test_disable_3',
'An inactive alert',
[
'active' => FALSE,
],
],
];
foreach ($alerts as [
$label,
$message,
$options,
]) {
$this->cliCommands
->create($label, $message, $options);
}
// There should be 2 active alerts.
$this
->assertActiveAlertCount(2);
// Disable all alerts. This should return the number of alerts that were
// disabled.
$count = $this->cliCommands
->disable(NULL, [
'all' => TRUE,
]);
$this
->assertEquals(2, $count);
$this
->assertActiveAlertCount(0);
// Try to disable all alerts again. This should return 0 indicating that no
// alerts were disabled.
$count = $this->cliCommands
->disable(NULL, [
'all' => TRUE,
]);
$this
->assertEquals(0, $count);
$this
->assertActiveAlertCount(0);
}