-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIx time conversion into seconds/hundredths
- Loading branch information
1 parent
0d15184
commit aadbbb7
Showing
3 changed files
with
79 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Author: huw | ||
* Since: 2019-10-26 | ||
*/ | ||
|
||
namespace RankingsDB\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use RankingsDB\Event; | ||
use RankingsDB\Stroke; | ||
use RankingsDB\Time; | ||
|
||
class TimeTest extends TestCase | ||
{ | ||
|
||
public function testGetTimeInSecondsHundredths() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "000012"); | ||
$this->assertEquals(0.12, $time->getTimeInSeconds()); | ||
} | ||
|
||
public function testGetTimeInSecondsSeconds() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "001234"); | ||
$this->assertEquals(12.34, $time->getTimeInSeconds()); | ||
} | ||
|
||
public function testGetTimeInSecondsMinutes() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "123456"); | ||
$this->assertEquals(754.56, $time->getTimeInSeconds()); | ||
} | ||
|
||
public function testGetTimeInHundredthsHundredths() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "000012"); | ||
$this->assertEquals(12, $time->getTimeInHundredths()); | ||
} | ||
|
||
public function testGetTimeInHundredthsSeconds() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "001234"); | ||
$this->assertEquals(1234, $time->getTimeInHundredths()); | ||
} | ||
|
||
public function testGetTimeInHundredthssMinutes() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "123456"); | ||
$this->assertEquals(75456, $time->getTimeInHundredths()); | ||
} | ||
|
||
public function testGetTimeNoLeadingZeroes() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "003456"); | ||
$this->assertEquals("34.56", $time->getTime(false)); | ||
} | ||
|
||
public function testGetTimeWithLeadingZeroes() | ||
{ | ||
$event = new Event(Stroke::FREESTYLE, 50); | ||
$time = new Time($event, "003456"); | ||
$this->assertEquals("0:34.56", $time->getTime(true)); | ||
} | ||
} |