shouldReceive('findAll')->withAnyArgs()->once()->andReturn([]); $employeeDirectory->shouldReceive('findAll') ->withAnyArgs() ->once() ->andReturn(new Paginated(Pagination::ofPage(1, 5), [], 0)); $incoSheetDirectory->shouldReceive('findAll') ->withAnyArgs() ->once() ->andReturn(new Paginated(Pagination::ofPage(1, 5), [], 0)); $incoCompoDirectory->shouldReceive('findByIncoId')->withAnyArgs()->once()->andReturn(null); $checker = new LaravelSystemHealthChecker( $storageConfig, $brandDirectory, $employeeDirectory, $incoSheetDirectory, $incoCompoDirectory, ); // WHEN $result = $checker->checkArcadiaConformity(); // THEN expect($result->isConform())->toBeTrue() ->and($result->status)->toBe(HealthStatus::HEALTHY) ->and(count($result->checks))->toBe(4) ->and($result->checks[0]->status)->toBe(ComponentStatus::UP) ->and($result->checks[1]->status)->toBe(ComponentStatus::UP) ->and($result->checks[2]->status)->toBe(ComponentStatus::UP) ->and($result->checks[3]->status)->toBe(ComponentStatus::UP); }); it('returns unhealthy status with captured dissonance when a directory probe fails', function (): void { // GIVEN $storageConfig = resolve(ArcadiaStorageConfig::class); $brandDirectory = mock(ArcadiaBrandDirectory::class); $employeeDirectory = mock(EmployeeDirectory::class); $incoSheetDirectory = mock(IncoSheetDirectory::class); $incoCompoDirectory = mock(IncoCompositionDirectory::class); $brandDirectory->shouldReceive('findAll') ->withAnyArgs() ->once() ->andThrow(new \RuntimeException('ORA-00904: "LIB_MARQ": invalid identifier')); $employeeDirectory->shouldReceive('findAll') ->withAnyArgs() ->once() ->andReturn(new Paginated(Pagination::ofPage(1, 5), [], 0)); $incoSheetDirectory->shouldReceive('findAll') ->withAnyArgs() ->once() ->andReturn(new Paginated(Pagination::ofPage(1, 5), [], 0)); $incoCompoDirectory->shouldReceive('findByIncoId') ->withAnyArgs() ->once() ->andReturn(null); $checker = new LaravelSystemHealthChecker( $storageConfig, $brandDirectory, $employeeDirectory, $incoSheetDirectory, $incoCompoDirectory, ); // WHEN $result = $checker->checkArcadiaConformity(); // THEN expect($result->isConform())->toBeFalse() ->and($result->hasDissonances())->toBeTrue() ->and($result->status)->toBe(HealthStatus::UNHEALTHY) ->and($result->checks[0]->status)->toBe(ComponentStatus::DOWN) ->and($result->checks[0]->errorMessage)->toContain('ORA-00904') ->and($result->checks[1]->status)->toBe(ComponentStatus::UP); }); });