Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions tests/ProgramScraperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
use PHPUnit\Framework\TestCase;

/**
* @psalm-import-type ScrapedStadiumRaces from ScraperInterface
* @psalm-import-type ScrapedRaces from ScraperInterface
*
* @author shimomo
*/
final class ProgramScraperTest extends Testcase
final class ProgramScraperTest extends TestCase
{
/**
* @psalm-return void
Expand All @@ -25,23 +25,29 @@ public function testScrape(): void
{
$mockScraper = $this->createMock(ScraperInterface::class);
$mockScraper->method('scrapePrograms')
->with(Carbon::create(2025, 7, 15))
->with(Carbon::create(2025, 7, 15, 0, 0, 0, 'Asia/Tokyo'))
->willReturn([
$this->testScrapeData(1),
1 => $this->testScrapeData(1, 5),
2 => $this->testScrapeData(2, 6),
]);
$scraper = new ProgramScraper($mockScraper);
$programs = $scraper->scrape(Carbon::create(2025, 7, 15));
$this->assertSame($this->testScrapeData(0), $programs);
$programs = $scraper->scrape(Carbon::create(2025, 7, 15, 0, 0, 0, 'Asia/Tokyo'));
$this->assertSame(array_merge(
$this->testScrapeData(0, 0),
$this->testScrapeData(1, 0)
), $programs);
}

/**
* @psalm-param int $keyIndex
* @psalm-return ScrapedStadiumRaces
* @psalm-param int $boatKeyIndex
* @psalm-return ScrapedRaces
*
* @param int $keyIndex
* @param int $boatKeyIndex
* @return array
*/
private function testScrapeData(int $keyIndex): array
private function testScrapeData(int $keyIndex, int $boatKeyIndex): array
{
return [
$keyIndex => [
Expand All @@ -54,7 +60,7 @@ private function testScrapeData(int $keyIndex): array
'race_subtitle' => '予選',
'race_distance' => 1800,
'boats' => [
$keyIndex => [
$boatKeyIndex => [
'racer_boat_number' => 1,
'racer_name' => '松本 浩貴',
'racer_number' => 3860,
Expand Down