Files
api/services/nginx/app/tests/Unit/Workfeed/DepartmentWeatherTimelineSchemaConformanceTest.php
T

44 lines
1.6 KiB
PHP

<?php
it('includes a date key in department weather timeline entries', function (): void {
$routeFile = app_path('routes/moduleWeatherAPIRoute.php');
$content = (string)file_get_contents($routeFile);
expect($content)->toContain("'date' => \$slot->format('Y-m-d')");
expect($content)->toContain("'current' => \$slot_key === \$current_slot_key");
});
it('documents the date key in the openapi department weather timeline schema', function (): void {
$candidates = [WD . '/openapi.yaml'];
for ($depth = 1; $depth <= 8; $depth++) {
$candidates[] = dirname(WD, $depth) . '/openapi.yaml';
}
$cwd = getcwd();
if (is_string($cwd) && $cwd !== '') {
$candidates[] = $cwd . DIRECTORY_SEPARATOR . 'openapi.yaml';
$candidates[] = dirname($cwd) . DIRECTORY_SEPARATOR . 'openapi.yaml';
}
$candidates = array_values(array_unique($candidates));
$openApiFile = null;
foreach ($candidates as $candidate) {
if (is_file($candidate)) {
$openApiFile = $candidate;
break;
}
}
if ($openApiFile === null) {
$this->markTestSkipped('openapi.yaml is not mounted in this test container.');
}
$content = (string)file_get_contents($openApiFile);
expect($content)->toContain('DepartmentWeatherTimelineEntry:');
expect($content)->toContain('format: date');
expect($content)->toContain('type: boolean');
expect($content)->toContain('required: [date, time, current, weather, washes, hours, status]');
expect($content)->toContain('- name: date_from');
expect($content)->toContain('- name: date_to');
});