From 6b8300c2f1ace7d12ded487528233a43c4615182 Mon Sep 17 00:00:00 2001 From: shimomo Date: Sun, 31 Aug 2025 17:37:09 +0900 Subject: [PATCH 1/4] test: improve scrape tests --- tests/ProgramScraperTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/ProgramScraperTest.php b/tests/ProgramScraperTest.php index 62f1f8fb..18adfe26 100644 --- a/tests/ProgramScraperTest.php +++ b/tests/ProgramScraperTest.php @@ -27,21 +27,27 @@ public function testScrape(): void $mockScraper->method('scrapePrograms') ->with(Carbon::create(2025, 7, 15)) ->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); + $this->assertSame(array_merge( + $this->testScrapeData(0, 0), + $this->testScrapeData(1, 0) + ), $programs); } /** * @psalm-param int $keyIndex + * @psalm-param int $boatKeyIndex * @psalm-return ScrapedStadiumRaces * * @param int $keyIndex + * @param int $boatKeyIndex * @return array */ - private function testScrapeData(int $keyIndex): array + private function testScrapeData(int $keyIndex, int $boatKeyIndex): array { return [ $keyIndex => [ @@ -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, From aa2668347b78cec71b5f462b9605d216b3337a41 Mon Sep 17 00:00:00 2001 From: shimomo Date: Sun, 31 Aug 2025 17:55:19 +0900 Subject: [PATCH 2/4] test: align timezones --- tests/ProgramScraperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ProgramScraperTest.php b/tests/ProgramScraperTest.php index 18adfe26..42c1de2b 100644 --- a/tests/ProgramScraperTest.php +++ b/tests/ProgramScraperTest.php @@ -25,13 +25,13 @@ 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([ 1 => $this->testScrapeData(1, 5), 2 => $this->testScrapeData(2, 6), ]); $scraper = new ProgramScraper($mockScraper); - $programs = $scraper->scrape(Carbon::create(2025, 7, 15)); + $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) From bb4180a348d911ed3ed446de89e94e8a3debec13 Mon Sep 17 00:00:00 2001 From: shimomo Date: Sun, 31 Aug 2025 18:05:41 +0900 Subject: [PATCH 3/4] test: fix typo --- tests/ProgramScraperTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ProgramScraperTest.php b/tests/ProgramScraperTest.php index 42c1de2b..823edc94 100644 --- a/tests/ProgramScraperTest.php +++ b/tests/ProgramScraperTest.php @@ -14,7 +14,7 @@ * * @author shimomo */ -final class ProgramScraperTest extends Testcase +final class ProgramScraperTest extends TestCase { /** * @psalm-return void From 2979ebf76c5df02a829cf34684cdac142fa9bd47 Mon Sep 17 00:00:00 2001 From: shimomo Date: Sun, 31 Aug 2025 18:22:11 +0900 Subject: [PATCH 4/4] docs: update PHPDoc comments --- tests/ProgramScraperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ProgramScraperTest.php b/tests/ProgramScraperTest.php index 823edc94..9b1bc160 100644 --- a/tests/ProgramScraperTest.php +++ b/tests/ProgramScraperTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase; /** - * @psalm-import-type ScrapedStadiumRaces from ScraperInterface + * @psalm-import-type ScrapedRaces from ScraperInterface * * @author shimomo */ @@ -41,7 +41,7 @@ public function testScrape(): void /** * @psalm-param int $keyIndex * @psalm-param int $boatKeyIndex - * @psalm-return ScrapedStadiumRaces + * @psalm-return ScrapedRaces * * @param int $keyIndex * @param int $boatKeyIndex