diff --git a/src/Models/Master.php b/src/Models/Master.php deleted file mode 100644 index 68c523d..0000000 --- a/src/Models/Master.php +++ /dev/null @@ -1,20 +0,0 @@ -gameEpoch = new \DateTime('2015-07-27 00:00:00 PDT');; - $this->gameOffsetSeconds = 0; - $this->gameDaysPerDay = 2; - } + public function setUp() { + $this->gameEpoch = new \DateTime('2015-07-27 00:00:00 PDT');; + $this->gameOffsetSeconds = 0; + $this->gameDaysPerDay = 2; + } - public function testConvertToBasicConversion() { - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + public function testConvertToBasicConversion() { + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $date = new \DateTime('2015-07-27 23:59:59 PDT'); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s')); + $date = new \DateTime('2015-07-27 23:59:59 PDT'); + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s')); - $date = new \DateTime('2015-07-27 12:00:00 PDT'); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-01 12:00:00', $converted->format('Y-m-d H:i:s')); - } + $date = new \DateTime('2015-07-27 12:00:00 PDT'); + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-01 12:00:00', $converted->format('Y-m-d H:i:s')); + } - public function testConvertToRespectsGameDaysPerDayUpperBound() { - $date = new \DateTime('2015-07-27 05:59:59 PDT'); + public function testConvertToRespectsGameDaysPerDayUpperBound() { + $date = new \DateTime('2015-07-27 05:59:59 PDT'); - $this->gameDaysPerDay = 4; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameDaysPerDay = 4; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-01', $converted->format('Y-m-d')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-01', $converted->format('Y-m-d')); + } - public function testConvertToRespectsGameDaysPerDayNextDay() { - $date = new \DateTime('2015-07-27 06:00:00 PDT'); + public function testConvertToRespectsGameDaysPerDayNextDay() { + $date = new \DateTime('2015-07-27 06:00:00 PDT'); - $this->gameDaysPerDay = 4; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameDaysPerDay = 4; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); + } - public function testConvertToRespectsGameDaysPerDayNextDayUpperBound() { - $date = new \DateTime('2015-07-27 11:59:59 PDT'); + public function testConvertToRespectsGameDaysPerDayNextDayUpperBound() { + $date = new \DateTime('2015-07-27 11:59:59 PDT'); - $this->gameDaysPerDay = 4; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameDaysPerDay = 4; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); + } - public function testIfIsNewDayReturnsTrueWithNullAsLastInteractionTime() { - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, 4); + public function testIfIsNewDayReturnsTrueWithNullAsLastInteractionTime() { + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, 4); - $this->assertTrue($keeper->isNewDay(null)); - } + $this->assertTrue($keeper->isNewDay(null)); + } - public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasJustRecently() - { - // game days per day: 4, each day 6h. - $keeper = new TimeKeeper($this->gameEpoch, new DateTime("2017-01-02 11:59:59"), 3600*5, 4); + public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasJustRecently() + { + // game days per day: 4, each day 6h. + $keeper = new TimeKeeper($this->gameEpoch, new DateTime("2017-01-02 11:59:59"), 3600*5, 4); - $time1 = new \DateTime("2017-01-02 06:00:00"); - $time2 = new \DateTime("2017-01-02 11:59:59"); - $time3 = new \DateTime("2017-01-02 09:00:00"); - $time4 = new \DateTime("2017-01-02 09:59:30"); + $time1 = new \DateTime("2017-01-02 06:00:00"); + $time2 = new \DateTime("2017-01-02 11:59:59"); + $time3 = new \DateTime("2017-01-02 09:00:00"); + $time4 = new \DateTime("2017-01-02 09:59:30"); - $this->assertFalse($keeper->isNewDay($time1)); - $this->assertFalse($keeper->isNewDay($time2)); - $this->assertFalse($keeper->isNewDay($time3)); - $this->assertFalse($keeper->isNewDay($time4)); - } + $this->assertFalse($keeper->isNewDay($time1)); + $this->assertFalse($keeper->isNewDay($time2)); + $this->assertFalse($keeper->isNewDay($time3)); + $this->assertFalse($keeper->isNewDay($time4)); + } public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasOnLastGameDay() { @@ -103,87 +103,87 @@ class TimeKeeperTests extends \PHPUnit_Framework_TestCase { $this->assertTrue($keeper->isNewDay($time4)); } - public function testConvertToRespectsGameOffset() { - $date = new \DateTime('2015-07-27 01:01:15 PDT'); + public function testConvertToRespectsGameOffset() { + $date = new \DateTime('2015-07-27 01:01:15 PDT'); - $this->gameOffsetSeconds = 60*60; - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameOffsetSeconds = 60*60; + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-01 00:01:15', $converted->format('Y-m-d H:i:s')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-01 00:01:15', $converted->format('Y-m-d H:i:s')); + } - public function testConvertToRespectsGameOffsetUpperBound() { - $date = new \DateTime('2015-07-28 00:59:59 PDT'); + public function testConvertToRespectsGameOffsetUpperBound() { + $date = new \DateTime('2015-07-28 00:59:59 PDT'); - $this->gameOffsetSeconds = 60*60; - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameOffsetSeconds = 60*60; + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s')); + } - public function testConvertToRespectsGameOffsetNextDay() { - $date = new \DateTime('2015-07-28 01:00:00 PDT'); + public function testConvertToRespectsGameOffsetNextDay() { + $date = new \DateTime('2015-07-28 01:00:00 PDT'); - $this->gameOffsetSeconds = 60*60; - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameOffsetSeconds = 60*60; + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); + } - public function testConvertToRespectsGameOffsetNextDayUpperBound() { - $date = new \DateTime('2015-07-29 00:59:59 PDT'); + public function testConvertToRespectsGameOffsetNextDayUpperBound() { + $date = new \DateTime('2015-07-29 00:59:59 PDT'); - $this->gameOffsetSeconds = 60*60; - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameOffsetSeconds = 60*60; + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertToGameTime($date); - $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); - } + $converted = $keeper->convertToGameTime($date); + $this->assertEquals('0000-01-02', $converted->format('Y-m-d')); + } - public function testConvertFromBasicConversion() { - $date = new \DateTime('0000-01-02 00:00:00 UTC'); + public function testConvertFromBasicConversion() { + $date = new \DateTime('0000-01-02 00:00:00 UTC'); - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertFromGameTime($date); - $this->assertEquals("2015-07-28", $converted->format('Y-m-d')); - } + $converted = $keeper->convertFromGameTime($date); + $this->assertEquals("2015-07-28", $converted->format('Y-m-d')); + } - public function testConvertFromRespectsGameOffsetNextDay() { - $epoch = new \DateTime('2015-07-27 00:00:00 PDT'); - $date = new \DateTime('0000-01-02 23:59:59 UTC'); + public function testConvertFromRespectsGameOffsetNextDay() { + $epoch = new \DateTime('2015-07-27 00:00:00 PDT'); + $date = new \DateTime('0000-01-02 23:59:59 UTC'); - $this->gameEpoch = $epoch; - $this->gameOffsetSeconds = 60*60; - $this->gameDaysPerDay = 1; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameEpoch = $epoch; + $this->gameOffsetSeconds = 60*60; + $this->gameDaysPerDay = 1; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertFromGameTime($date); - $this->assertEquals("2015-07-29 00:59:59", $converted->format('Y-m-d H:i:s')); - } + $converted = $keeper->convertFromGameTime($date); + $this->assertEquals("2015-07-29 00:59:59", $converted->format('Y-m-d H:i:s')); + } - public function testConvertFromRespectsGameDaysPerDayNextDay() { - $epoch = new \DateTime('2015-07-27 00:00:00 PDT'); - $date = new \DateTime('0000-01-02 23:59:59 UTC'); + public function testConvertFromRespectsGameDaysPerDayNextDay() { + $epoch = new \DateTime('2015-07-27 00:00:00 PDT'); + $date = new \DateTime('0000-01-02 23:59:59 UTC'); - $this->gameEpoch = $epoch; - $this->gameDaysPerDay = 4; - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->gameEpoch = $epoch; + $this->gameDaysPerDay = 4; + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $converted = $keeper->convertFromGameTime($date); - $this->assertEquals("2015-07-27 11:59:59", $converted->format('Y-m-d H:i:s')); - } + $converted = $keeper->convertFromGameTime($date); + $this->assertEquals("2015-07-27 11:59:59", $converted->format('Y-m-d H:i:s')); + } - public function testGameTimeSanity() { - $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); - $this->assertNotNull($keeper->getGameTime()); - } + public function testGameTimeSanity() { + $keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay); + $this->assertNotNull($keeper->getGameTime()); + } }