You are here

public function DrushCommandsTest::testCreateEndNoStart in Site Alert 8

Tests site-alert:create with and end, but no start.

When the start date is omitted it should default to now.

File

tests/src/Functional/DrushCommandsTest.php, line 99

Class

DrushCommandsTest
Execute drush commands on site_alert.

Namespace

Drupal\Tests\site_alert\Functional

Code

public function testCreateEndNoStart() : void {
  $label = 'automated-test-alert-no-start';
  $message = 'A site alert test.';

  // Set the end date comfortably in the future.
  $next_year = date('Y') + 1;
  $end_time = $next_year . '-10-15T15:00:00';
  $scheduling_options = [
    'end' => $end_time,
  ];
  $this
    ->drush('site-alert:create', [
    $label,
    $message,
  ], $scheduling_options);
  $this
    ->assertErrorOutputEquals("[success] Created site alert 'automated-test-alert-no-start'.");
  $this
    ->assertAlertCount(1);
  $this
    ->assertAlertByLabel($label, $message, 'medium', TRUE, $scheduling_options);
  $this
    ->drush('site-alert:delete', [
    $label,
  ]);
  $this
    ->assertErrorOutputEquals("[success] Deleted 1 site alerts labelled 'automated-test-alert-no-start'.");
  $this
    ->assertAlertCount(0);
}