38 lines
1.8 KiB
PHP
38 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Services\Autopodbor\Agent\ChannelA\CategoryListingParser;
|
||
|
|
use App\Services\Autopodbor\Agent\Extract\DirectoryParser;
|
||
|
|
use App\Services\Autopodbor\Agent\Extract\HtmlTwoGisReader;
|
||
|
|
use App\Services\Autopodbor\Agent\Extract\TwoGisReader;
|
||
|
|
|
||
|
|
// HtmlTwoGisReader — шов xf4-пути: тонкий делегат к нынешним HTML-парсерам. Контракт-идентичность:
|
||
|
|
// его выход по каждому из трёх типов ДОЛЖЕН совпадать с прямым вызовом парсера (поведение 1:1).
|
||
|
|
|
||
|
|
beforeEach(function () {
|
||
|
|
$this->reader = new HtmlTwoGisReader(new CategoryListingParser, new DirectoryParser);
|
||
|
|
$this->searchHtml = file_get_contents(base_path('tests/fixtures/autopodbor/2gis-search-kraslombard.html'));
|
||
|
|
$this->firmHtml = file_get_contents(base_path('tests/fixtures/autopodbor/2gis-firm-kraslombard.html'));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('реализует интерфейс TwoGisReader', function () {
|
||
|
|
expect($this->reader)->toBeInstanceOf(TwoGisReader::class);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('listing делегирует в CategoryListingParser::parse 1:1', function () {
|
||
|
|
expect($this->reader->listing($this->searchHtml))
|
||
|
|
->toEqual((new CategoryListingParser)->parse($this->searchHtml));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('card делегирует в DirectoryParser::parse2gisCard 1:1', function () {
|
||
|
|
$url = 'https://2gis.ru/krasnoyarsk/firm/70000001052966157';
|
||
|
|
expect($this->reader->card($this->firmHtml, $url))
|
||
|
|
->toEqual((new DirectoryParser)->parse2gisCard($this->firmHtml, $url));
|
||
|
|
});
|
||
|
|
|
||
|
|
it('branchList делегирует в DirectoryParser::parseBranchList 1:1', function () {
|
||
|
|
expect($this->reader->branchList($this->searchHtml))
|
||
|
|
->toEqual((new DirectoryParser)->parseBranchList($this->searchHtml));
|
||
|
|
});
|