public function GetAlertsTest::testGetActiveAlertIds in Site Alert 8
Tests the retrieval of active alert IDs.
@covers ::getActiveAlertIds @dataProvider getActiveAlertsProvider
Parameters
array $alerts_to_create: An array of identifiers for the site alerts that should be created at the start of the test.
array $expected_alerts: An array of identifiers for the site alerts that are expected to be returned by the method under test.
File
- tests/
src/ Kernel/ GetAlertsTest.php, line 42
Class
- GetAlertsTest
- Tests retrieving of currently active alerts.
Namespace
Drupal\Tests\site_alert\KernelCode
public function testGetActiveAlertIds(array $alerts_to_create, array $expected_alerts) {
// Populate the database with the alerts as specified in the test case.
$this
->createAlerts($alerts_to_create);
// Retrieve the active alerts.
$actual_alert_ids = $this->getAlerts
->getActiveAlertIds();
$expected_alert_ids = array_map(function ($alert_id) {
return $this->alerts[$alert_id]
->id();
}, $expected_alerts);
sort($actual_alert_ids);
sort($expected_alert_ids);
$this
->assertEquals($actual_alert_ids, $expected_alert_ids);
}