fix(models): correct UserSetting import namespace and add test coverage
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user