You are here

protected function SiteAlertTestTrait::loadAlertByLabel in Site Alert 8

Returns the site alert with the given label.

This assumes that there is exactly 1 site alert with the given label.

Parameters

string $label: The label to search for.

Return value

\Drupal\site_alert\Entity\SiteAlert The site alert entity.

3 calls to SiteAlertTestTrait::loadAlertByLabel()
CliCommandsTest::testCreateSiteAlert in tests/src/Kernel/CliCommandsTest.php
Test site alert creation with message and severity.
CliCommandsTest::testCreateSiteAlertWithOptions in tests/src/Kernel/CliCommandsTest.php
Test site alert creation with severity and scheduling options.
SiteAlertTestTrait::assertAlertByLabel in tests/src/Traits/SiteAlertTestTrait.php
Checks that the site alert with the given label contains the given data.

File

tests/src/Traits/SiteAlertTestTrait.php, line 133

Class

SiteAlertTestTrait
Helper methods for testing the Site Alert module.

Namespace

Drupal\Tests\site_alert\Traits

Code

protected function loadAlertByLabel(string $label) : SiteAlert {
  $alerts = $this
    ->loadAlertsByLabel($label);
  $this
    ->assertCount(1, $alerts);
  return reset($alerts);
}