44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Data;
|
|
|
|
use App\Features\Scraper\Data\ScraperResultData;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\TestCase;
|
|
|
|
class ScraperResultDataTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function it_can_be_created_from_array(): void
|
|
{
|
|
$data = ScraperResultData::from([
|
|
'id' => 123,
|
|
'title' => 'Super Mario Bros',
|
|
'cover_url' => 'https://example.com/cover.jpg',
|
|
'year' => '1985',
|
|
'source' => 'igdb',
|
|
]);
|
|
|
|
$this->assertEquals(123, $data->id);
|
|
$this->assertEquals('Super Mario Bros', $data->title);
|
|
$this->assertEquals('https://example.com/cover.jpg', $data->coverUrl);
|
|
$this->assertEquals('1985', $data->year);
|
|
$this->assertEquals('igdb', $data->source);
|
|
}
|
|
|
|
#[Test]
|
|
public function it_handles_null_optional_fields(): void
|
|
{
|
|
$data = ScraperResultData::from([
|
|
'id' => 1,
|
|
'title' => 'Test Game',
|
|
'cover_url' => null,
|
|
'year' => null,
|
|
'source' => 'thegamesdb',
|
|
]);
|
|
|
|
$this->assertNull($data->coverUrl);
|
|
$this->assertNull($data->year);
|
|
}
|
|
}
|