13 - Add language and languageConfidence fields to FetchResult
This commit is contained in:
parent
829ce04282
commit
cb83b0df90
2 changed files with 10 additions and 0 deletions
|
|
@ -22,5 +22,7 @@ public function __construct(
|
||||||
public Collection $outboundLinks,
|
public Collection $outboundLinks,
|
||||||
public ?int $wordCount,
|
public ?int $wordCount,
|
||||||
public ?string $errorMessage,
|
public ?string $errorMessage,
|
||||||
|
public ?string $language = null,
|
||||||
|
public ?float $languageConfidence = null,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ public function test_it_exposes_all_fields(): void
|
||||||
outboundLinks: collect(['https://other.com', 'https://another.com']),
|
outboundLinks: collect(['https://other.com', 'https://another.com']),
|
||||||
wordCount: 5,
|
wordCount: 5,
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
|
language: 'en',
|
||||||
|
languageConfidence: 0.95,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame(CrawlOutcomeEnum::Success, $result->outcome);
|
$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(['https://other.com', 'https://another.com'], $result->outboundLinks->all());
|
||||||
$this->assertSame(5, $result->wordCount);
|
$this->assertSame(5, $result->wordCount);
|
||||||
$this->assertNull($result->errorMessage);
|
$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
|
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(),
|
outboundLinks: collect(),
|
||||||
wordCount: null,
|
wordCount: null,
|
||||||
errorMessage: 'Could not connect',
|
errorMessage: 'Could not connect',
|
||||||
|
language: null,
|
||||||
|
languageConfidence: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame(CrawlOutcomeEnum::Failed, $result->outcome);
|
$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->assertSame([], $result->outboundLinks->all());
|
||||||
$this->assertNull($result->wordCount);
|
$this->assertNull($result->wordCount);
|
||||||
$this->assertSame('Could not connect', $result->errorMessage);
|
$this->assertSame('Could not connect', $result->errorMessage);
|
||||||
|
$this->assertNull($result->language);
|
||||||
|
$this->assertNull($result->languageConfidence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue