-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1468 from weather-gov/mgwalker/1407-alert-list-re…
…factor Refactor alert metadata and add an alert metadata page
- Loading branch information
Showing
9 changed files
with
860 additions
and
245 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
web/modules/weather_blocks/src/Plugin/Block/AlertInfoBlock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Drupal\weather_blocks\Plugin\Block; | ||
|
||
use Drupal\weather_data\Service\AlertUtility; | ||
use Drupal\weather_data\Service\DateTimeUtility; | ||
|
||
/** | ||
* Provides a block of alert information | ||
* | ||
* @Block( | ||
* id = "weathergov_info_alert", | ||
* admin_label = @Translation("Alert info block"), | ||
* category = @Translation("weather.gov"), | ||
* ) | ||
*/ | ||
class AlertInfoBlock extends WeatherBlockBase | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build() | ||
{ | ||
return ["alertTypes" => AlertUtility::getAlertTypes()]; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
web/modules/weather_blocks/src/Plugin/Block/Test/EndToEnd/Alerts/AlertInfo.php.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Drupal\weather_blocks\Plugin\Block\Test\EndToEnd; | ||
|
||
use Drupal\weather_blocks\Plugin\Block\AlertInfoBlock; | ||
|
||
/** | ||
* Tests for alert info data structure. | ||
*/ | ||
final class AlertInfoStructureTest extends EndToEndBase | ||
{ | ||
/** | ||
* Create the block under test. | ||
*/ | ||
protected function setUp($type = null): void | ||
{ | ||
parent::setUp(AlertInfoBlock::class); | ||
} | ||
|
||
/** | ||
* Simply validate the data structure. | ||
* @group e2e | ||
*/ | ||
public function testAlertDataStructure(): void | ||
{ | ||
$schema = SchemaHelper::load("alertInfo.json"); | ||
|
||
$data = $this->block->build(); | ||
$schema->in($data["alertTypes"]); | ||
|
||
$this->assertTrue(true); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
web/modules/weather_blocks/src/Plugin/Block/Test/EndToEnd/schemas/alertInfo.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"alert": { | ||
"type": "string" | ||
}, | ||
"kind": { "type": "string" }, | ||
"level": { "type": "string" }, | ||
"priority": { "type": "number" } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.