-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false-pos test and reformat things
- Loading branch information
Showing
8 changed files
with
66 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor | ||
\.phpunit\.result\.cache | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
<?php | ||
require('../vendor/autoload.php'); | ||
|
||
use CobaltGrid\Aviation\AIRACCalculator; | ||
use Carbon\Carbon; | ||
use CobaltGrid\Aviation\AIRACCalculator; | ||
|
||
$date = Carbon::now(); | ||
if($_GET['date']){ | ||
if ($_GET['date']) { | ||
$date = new Carbon($_GET['date']); | ||
} | ||
?> | ||
|
||
<form> | ||
Date (in format 19 JUN 2019 10:30): | ||
<input type='text' name='date' /> | ||
<input type='submit' value='Submit' /> | ||
</form> | ||
<form> | ||
Date (in format 19 JUN 2019 10:30): | ||
<input type='text' name='date'/> | ||
<input type='submit' value='Submit'/> | ||
</form> | ||
|
||
<?php | ||
|
||
echo "'Current' Date: ".$date->format('d M Y H:i')."</br>"; | ||
echo "'Current' Date: " . $date->format('d M Y H:i') . "</br>"; | ||
echo "The current AIRAC is " . AIRACCalculator::currentAiracCycle($date) . ", which became effective at " . AIRACCalculator::dateForCycle(AIRACCalculator::currentAiracCycle($date))->format('d/m/Y') . '</br>'; | ||
echo "The next effective AIRAC is " . AIRACCalculator::nextAiracCycle($date) . ", which becomes effective at " . AIRACCalculator::nextAiracDate($date)->format('d/m/Y'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,66 @@ | ||
<?php | ||
|
||
use Carbon\Carbon; | ||
use PHPUnit\Framework\TestCase; | ||
use CobaltGrid\Aviation\AIRACCalculator; | ||
use Symfony\Component\DomCrawler\Crawler; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class CurrentAiracTest extends TestCase | ||
{ | ||
public function testItReportsCorrectCurrentAirac(): void | ||
{ | ||
// 1906 cycle effective at 23 MAY 19 | ||
// 1907 cycle effective at 20 JUN 19 | ||
|
||
Carbon::setTestNow(new Carbon('19 JUN 19 10:10:10')); | ||
$this->assertEquals('1906', AIRACCalculator::currentAiracCycle()); | ||
|
||
Carbon::setTestNow(new Carbon('19 JUN 19 23:59:59')); | ||
$this->assertEquals('1906', AIRACCalculator::currentAiracCycle()); | ||
|
||
|
||
Carbon::setTestNow(new Carbon('20 JUN 19')); | ||
$this->assertEquals('1907', AIRACCalculator::currentAiracCycle()); | ||
|
||
Carbon::setTestNow(); | ||
} | ||
|
||
public function testItReportsCorrectlyOverAYear(): void | ||
{ | ||
// 2014 cycle effective at 31 DEC 20 | ||
// 2101 cycle effective at 28 JAN 21 | ||
|
||
Carbon::setTestNow(new Carbon('10 JAN 21')); | ||
$this->assertEquals('2014', AIRACCalculator::currentAiracCycle()); | ||
|
||
Carbon::setTestNow(); | ||
} | ||
|
||
public function testItCorrectlyIndicatesIfTodayIsNewAirac(): void | ||
{ | ||
// 1906 cycle effective at 23 MAY 19 | ||
// 1907 cycle effective at 20 JUN 19 | ||
|
||
Carbon::setTestNow(new Carbon('20 JUN 19')); | ||
$this->assertTrue(AIRACCalculator::isNewAiracDay()); | ||
|
||
Carbon::setTestNow(new Carbon('20 JUN 19 14:35:59')); | ||
$this->assertTrue(AIRACCalculator::isNewAiracDay()); | ||
|
||
Carbon::setTestNow(new Carbon('19 JUN 19 23:59:59')); | ||
$this->assertFalse(AIRACCalculator::isNewAiracDay()); | ||
|
||
Carbon::setTestNow(); | ||
} | ||
|
||
public function testItCorrectlyIndicatesIfADateIsNewAirac(): void | ||
{ | ||
// 1906 cycle effective at 23 MAY 19 | ||
// 1907 cycle effective at 20 JUN 19 | ||
|
||
$this->assertTrue(AIRACCalculator::isNewAiracDay(new Carbon('20 JUN 19'))); | ||
|
||
$this->assertTrue(AIRACCalculator::isNewAiracDay(new Carbon('20 JUN 19 14:35:59'))); | ||
|
||
$this->assertFalse(AIRACCalculator::isNewAiracDay(new Carbon('19 JUN 19 23:59:59'))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters