trove/tests/Unit/ValueObjects/FetchResultTest.php

38 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\ValueObjects;
use App\Enums\CrawlOutcomeEnum;
use App\ValueObjects\FetchResult;
use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
class FetchResultTest extends TestCase
{
public function test_it_exposes_all_fields(): void
{
$result = new FetchResult(
outcome: CrawlOutcomeEnum::Success,
statusCode: 200,
finalUrl: 'https://example.com/article',
title: 'An Example Article',
extractedText: 'Lorem ipsum dolor sit amet.',
outboundLinks: collect(['https://other.com', 'https://another.com']),
wordCount: 5,
errorMessage: null,
);
$this->assertSame(CrawlOutcomeEnum::Success, $result->outcome);
$this->assertSame(200, $result->statusCode);
$this->assertSame('https://example.com/article', $result->finalUrl);
$this->assertSame('An Example Article', $result->title);
$this->assertSame('Lorem ipsum dolor sit amet.', $result->extractedText);
$this->assertInstanceOf(Collection::class, $result->outboundLinks);
$this->assertSame(['https://other.com', 'https://another.com'], $result->outboundLinks->all());
$this->assertSame(5, $result->wordCount);
$this->assertNull($result->errorMessage);
}
}