feat(api): humidity, CO2, current pressure and 24h pressure history
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Weerscherm\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Weerscherm\PressureHistory;
|
||||
|
||||
final class PressureHistoryTest extends TestCase
|
||||
{
|
||||
public function testMapsAndSortsPoints(): void
|
||||
{
|
||||
$body = json_decode((string) file_get_contents(__DIR__ . '/fixtures/getmeasure-pressure.json'), true)['body'];
|
||||
$shuffled = array_reverse($body, true);
|
||||
|
||||
$points = PressureHistory::map($shuffled, new \DateTimeZone('Europe/Berlin'));
|
||||
|
||||
self::assertCount(49, $points);
|
||||
self::assertSame('2026-09-10T14:30:00+02:00', $points[0]['at']);
|
||||
self::assertSame('2026-09-11T14:30:00+02:00', $points[48]['at']);
|
||||
self::assertIsFloat($points[0]['hpa']);
|
||||
self::assertSame(['at', 'hpa'], array_keys($points[0]));
|
||||
}
|
||||
|
||||
public function testSkipsGarbage(): void
|
||||
{
|
||||
$points = PressureHistory::map(['abc' => [1000.0], '1789129800' => ['x'], '1789133400' => [1013.5]], new \DateTimeZone('UTC'));
|
||||
|
||||
self::assertSame([['at' => '2026-09-11T13:30:00+00:00', 'hpa' => 1013.5]], $points);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user