From cb83b0df9057bf8072af09a0a8e115e955b3641c Mon Sep 17 00:00:00 2001 From: myrmidex Date: Tue, 28 Apr 2026 00:38:46 +0200 Subject: [PATCH] 13 - Add language and languageConfidence fields to FetchResult --- app/ValueObjects/FetchResult.php | 2 ++ tests/Unit/ValueObjects/FetchResultTest.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/ValueObjects/FetchResult.php b/app/ValueObjects/FetchResult.php index d79cdae..3514b37 100644 --- a/app/ValueObjects/FetchResult.php +++ b/app/ValueObjects/FetchResult.php @@ -22,5 +22,7 @@ public function __construct( public Collection $outboundLinks, public ?int $wordCount, public ?string $errorMessage, + public ?string $language = null, + public ?float $languageConfidence = null, ) {} } diff --git a/tests/Unit/ValueObjects/FetchResultTest.php b/tests/Unit/ValueObjects/FetchResultTest.php index c3185f8..463dcb7 100644 --- a/tests/Unit/ValueObjects/FetchResultTest.php +++ b/tests/Unit/ValueObjects/FetchResultTest.php @@ -22,6 +22,8 @@ public function test_it_exposes_all_fields(): void outboundLinks: collect(['https://other.com', 'https://another.com']), wordCount: 5, errorMessage: null, + language: 'en', + languageConfidence: 0.95, ); $this->assertSame(CrawlOutcomeEnum::Success, $result->outcome); @@ -33,6 +35,8 @@ public function test_it_exposes_all_fields(): void $this->assertSame(['https://other.com', 'https://another.com'], $result->outboundLinks->all()); $this->assertSame(5, $result->wordCount); $this->assertNull($result->errorMessage); + $this->assertSame('en', $result->language); + $this->assertSame(0.95, $result->languageConfidence); } public function test_it_accepts_null_for_failure_outcome_fields(): void @@ -46,6 +50,8 @@ public function test_it_accepts_null_for_failure_outcome_fields(): void outboundLinks: collect(), wordCount: null, errorMessage: 'Could not connect', + language: null, + languageConfidence: null, ); $this->assertSame(CrawlOutcomeEnum::Failed, $result->outcome); @@ -56,5 +62,7 @@ public function test_it_accepts_null_for_failure_outcome_fields(): void $this->assertSame([], $result->outboundLinks->all()); $this->assertNull($result->wordCount); $this->assertSame('Could not connect', $result->errorMessage); + $this->assertNull($result->language); + $this->assertNull($result->languageConfidence); } }