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

50 lines
2.8 KiB
PHP

<?php
it('registers and implements cron preloading for department weather cache', function (): void {
$cronContent = file_get_contents(app_path('cron/Cron.php'));
$routeContent = file_get_contents(app_path('routes/moduleWeatherAPIRoute.php'));
expect($cronContent)->not->toBeFalse();
expect($routeContent)->not->toBeFalse();
expect($cronContent)->toContain('PreloadDepartmentWeatherResponsesCron');
expect($cronContent)->toContain("'function' => 'PreloadDepartmentWeatherResponsesCron'");
expect($cronContent)->toContain("'interval' => 60");
expect($cronContent)->toContain('moduleWeatherAPIRoute::preloadDepartmentWeatherTimelineCache');
expect($cronContent)->toContain('moduleWeatherAPIRoute::getDepartmentWeatherHotPreloadTargets');
expect($cronContent)->toContain('DEPARTMENTS_WEATHER_PRELOAD_MAX_DEPARTMENTS');
expect($cronContent)->toContain('DEPARTMENTS_WEATHER_PRELOAD_HOT_LIMIT');
expect($cronContent)->toContain('DEPARTMENTS_WEATHER_PRELOAD_HOT_TTL');
expect($routeContent)->toContain('public static function preloadDepartmentWeatherTimelineCache');
expect($routeContent)->toContain('public static function getDepartmentWeatherHotPreloadTargets');
expect($routeContent)->toContain('withCachedDepartmentWeatherTimeline');
expect($routeContent)->toContain('getDepartmentWeatherCacheKey');
});
it('registers and implements cron warming for workfeed employee name cache', function (): void {
$cronContent = file_get_contents(app_path('cron/Cron.php'));
$routeContent = file_get_contents(app_path('routes/moduleWeatherAPIRoute.php'));
expect($cronContent)->not->toBeFalse();
expect($routeContent)->not->toBeFalse();
expect($cronContent)->toContain('WarmWorkfeedEmployeeNamesCron');
expect($cronContent)->toContain("'function' => 'WarmWorkfeedEmployeeNamesCron'");
expect($cronContent)->toContain("'interval' => 21600");
expect($cronContent)->toContain('WORKFEED_EMPLOYEE_NAME_CACHE_TTL');
expect($cronContent)->toContain('cache_workfeed_employee_name');
expect($cronContent)->toContain('normalizeWorkfeedEmployeeWarmupCollection');
expect($cronContent)->toContain('extractWorkfeedEmployeeWarmupIdentity');
expect($cronContent)->toContain('extractWorkfeedEmployeeWarmupIds');
expect($cronContent)->toContain('foreach ($employeeIds as $employeeId)');
expect($cronContent)->toContain('workfeed_employee_name_formatter::fromRecord');
expect($cronContent)->toContain("'firstname'");
expect($cronContent)->toContain("'lastname'");
expect($cronContent)->toContain("'employee.firstname'");
expect($cronContent)->toContain("'employee.lastname'");
expect($routeContent)->toContain('fetchCachedWorkfeedEmployeeDisplayName');
expect($routeContent)->toContain('get_workfeed_employee_name');
});