mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Improve meta extraction with AI self-healing and HTML microdata support. - AI self-heal the existing-store and auto-create extraction paths when no price is found, returning the detected/updated store (AiConfigHealer::applyPreviewToStore) - Expose scrape_settings and settings on StoreResource - Microdata (itemprop / <data>) fallback extraction across SchemaOrgService, StrategyExtractor and AutoCreateStore, with JSON-LD precedence locked by a test - Use filled() for the price heal-gate; parseSchemaOrg returns ?string for ImageObject arrays
32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services;
|
|
|
|
use App\Services\AutoCreateStore;
|
|
use Tests\TestCase;
|
|
|
|
class AutoCreateStoreMicrodataTest extends TestCase
|
|
{
|
|
private function microdataHtml(): string
|
|
{
|
|
return '<html><body><div itemscope itemtype="https://schema.org/Product">'
|
|
.'<h1 itemprop="name">Premium Leather Boots</h1>'
|
|
.'<div itemprop="offers" itemscope itemtype="https://schema.org/Offer">'
|
|
.'<span itemprop="price" content="149.99">149.99</span>'
|
|
.'</div></div></body></html>';
|
|
}
|
|
|
|
public function test_detects_a_store_strategy_from_microdata(): void
|
|
{
|
|
$detected = AutoCreateStore::new('https://shop.test/boots', $this->microdataHtml())
|
|
->setLogErrors(false)
|
|
->detect();
|
|
|
|
$this->assertNotNull($detected);
|
|
$this->assertSame('schema_org', data_get($detected, 'fields.title.type'));
|
|
$this->assertSame('schema_org', data_get($detected, 'fields.price.type'));
|
|
$this->assertSame('Premium Leather Boots', data_get($detected, 'extracted.title'));
|
|
$this->assertSame(149.99, data_get($detected, 'extracted.price'));
|
|
}
|
|
}
|