|
1 | 1 | <?php declare(strict_types=1); |
2 | 2 |
|
3 | 3 | use HelioviewerEventInterface\Events; |
| 4 | +use HelioviewerEventInterface\Translator\FlarePrediction; |
| 5 | +use HelioviewerEventInterface\Util\Date; |
4 | 6 | use PHPUnit\Framework\TestCase; |
5 | 7 | use function HelioviewerEventInterface\Translator\CreateShortLabel; |
6 | 8 | use HelioviewerEventInterface\Util\HapiRecord; |
7 | | - |
| 9 | +use PHPUnit\TextUI\XmlConfiguration\Group; |
8 | 10 |
|
9 | 11 | final class FlarePredictionTest extends TestCase |
10 | 12 | { |
@@ -171,5 +173,45 @@ public function testShortLabel(): void { |
171 | 173 |
|
172 | 174 | $this->assertEquals("\nC+: 5%\nM+: 1%\nX: 1%", CreateShortLabel($hapi_record)); |
173 | 175 | } |
| 176 | + |
| 177 | + static private function MakeEvent(float $lat, float $lon): array { |
| 178 | + return [ |
| 179 | + 'source' => [ |
| 180 | + 'NOAALatitude' => $lat, |
| 181 | + 'NOAALongitude' => $lon, |
| 182 | + 'NOAALocationTime' => Date::FormatDate(new DateTimeImmutable()), |
| 183 | + 'issue_time' => new DateTimeImmutable(), |
| 184 | + ] |
| 185 | + ]; |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * We've found that some CCMC Flare Scoreboard predictions have an invalid |
| 190 | + * coordinate. The FlarePrediction translator filters these out. |
| 191 | + * The FlarePrediction module now filters any records where the latitude |
| 192 | + * and longitude are out of bounds. |
| 193 | + */ |
| 194 | + #[Group('coordinator')] |
| 195 | + public function testFlarePredictionInvalidCoordinates(): void { |
| 196 | + $data = FlarePrediction::Transform([ |
| 197 | + 'groups' => [[ |
| 198 | + 'data' => [ |
| 199 | + // Invalid coordinate |
| 200 | + self::MakeEvent(106, 130), |
| 201 | + // Edge cases out of bounds |
| 202 | + self::MakeEvent(90.01, 0), |
| 203 | + self::MakeEvent(-90.01, 0), |
| 204 | + self::MakeEvent(0, 180.01), |
| 205 | + self::MakeEvent(0, -180.01), |
| 206 | + // Edge cases in-bound |
| 207 | + self::MakeEvent(90, 180), |
| 208 | + self::MakeEvent(-90, -180), |
| 209 | + ] |
| 210 | + ]] |
| 211 | + ], new DateTimeImmutable()); |
| 212 | + $this->assertCount(2, $data['groups'][0]['data']); |
| 213 | + $this->assertArrayHasKey(0, $data['groups'][0]['data']); |
| 214 | + $this->assertArrayHasKey(1, $data['groups'][0]['data']); |
| 215 | + } |
174 | 216 | } |
175 | 217 |
|
0 commit comments