Skip to content

Commit

Permalink
ci: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff committed Mar 28, 2024
1 parent 486eb0d commit 8144f50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"CobaltGrid\\AIRACCalculator\\": "src/"
}
},
"scripts": {
"test": "phpunit"
},
"require-dev": {
"phpunit/phpunit": "^8.2|^9.0",
"symfony/dom-crawler": "^4.3",
Expand Down
10 changes: 7 additions & 3 deletions tests/AccuracyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testItIsTheSameAsOfficalSource(): void

$years = $crawler->filter('table table');
// Check that it finds 3/4/5 years as expected
$this->assertContains(count($years), [3, 4, 5]);
$this->assertContains(count($years), [3, 4, 5, 6]);

foreach ($years as $year) {
$year = new Crawler($year);
Expand All @@ -24,8 +24,12 @@ public function testItIsTheSameAsOfficalSource(): void
$cycle = $cycles->eq($i);

$cycleNumber = $cycle->filter('td:nth-of-type(2)')->text();
$cycleDate = new DateTime($cycle->filter('td:nth-of-type(5)')->text(), new DateTimeZone('UTC'));
$this->assertEquals($cycleDate, AIRACCycle::fromCycleCode($cycleNumber)->getEffectiveDate());
$cycleDateRaw = $cycle->filter('td:nth-of-type(5)')->text();

preg_match("/\d{2} [A-Z]{3} \d{2,4}/", $cycleDateRaw, $matches);

$cycleDate = new DateTime($matches[0], new DateTimeZone('UTC'));
$this->assertEquals($cycleDate, AIRACCycle::fromCycleCode($cycleNumber)->getEffectiveDate(), "Cycle $cycleNumber does not match official source.");
}
}
}
Expand Down

0 comments on commit 8144f50

Please sign in to comment.