mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Add a meta-extraction API endpoint and refactor store scrape strategies onto strongly-typed DTOs. - POST /api/meta-extraction endpoint with SSRF protection on the target URL - Typed scrape-strategy DTOs and enums (StandardStrategyDto, AvailabilityMatchDto, AvailabilityMatchType, AvailabilityStrategyDto, StoreScraperStrategySetDto) with a model cast for the stores.scrape_strategy column - Convert ScrapeUrl, StrategyExtractor and availability resolution to consume the typed strategy slots; preserve legacy plain-string availability match entries - Filament scrape_strategy form bridge plus DTO test coverage
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Dto;
|
|
|
|
use App\Dto\AvailabilityMatchDto;
|
|
use App\Enums\AvailabilityMatchType;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AvailabilityMatchDtoTest extends TestCase
|
|
{
|
|
public function test_from_array_builds_dto(): void
|
|
{
|
|
$dto = AvailabilityMatchDto::fromArray(['type' => 'regex', 'value' => 'sold.?out']);
|
|
|
|
$this->assertSame(AvailabilityMatchType::Regex, $dto->type);
|
|
$this->assertSame('sold.?out', $dto->value);
|
|
}
|
|
|
|
public function test_from_array_defaults_type_to_match(): void
|
|
{
|
|
$dto = AvailabilityMatchDto::fromArray(['value' => 'Sold out']);
|
|
|
|
$this->assertSame(AvailabilityMatchType::Match, $dto->type);
|
|
}
|
|
|
|
public function test_from_array_returns_null_when_value_blank(): void
|
|
{
|
|
$this->assertNull(AvailabilityMatchDto::fromArray(null));
|
|
$this->assertNull(AvailabilityMatchDto::fromArray(['type' => 'match', 'value' => '']));
|
|
$this->assertNull(AvailabilityMatchDto::fromArray(['type' => 'match']));
|
|
}
|
|
|
|
public function test_to_array_round_trips(): void
|
|
{
|
|
$this->assertEquals(
|
|
['type' => 'match', 'value' => 'Sold out'],
|
|
AvailabilityMatchDto::fromArray(['type' => 'match', 'value' => 'Sold out'])->toArray(),
|
|
);
|
|
}
|
|
}
|