-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc0a152
commit 09f8c34
Showing
3 changed files
with
107 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace JikanTest\Model\Common; | ||
|
||
use Jikan\Model\Common\DateProp; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class DatePropTest | ||
*/ | ||
class DatePropTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_gets_date_props() | ||
{ | ||
$date = DateProp::fromFactory(null, null, null); | ||
self::assertInstanceOf(DateProp::class, $date); | ||
self::assertEquals(null, $date->getDay()); | ||
|
||
$date = new DateProp('Dec 1, 2004'); | ||
self::assertInstanceOf(DateProp::class, $date); | ||
self::assertEquals(1, $date->getDay()); | ||
self::assertEquals(12, $date->getMonth()); | ||
self::assertEquals(2004, $date->getYear()); | ||
|
||
$date = new DateProp('Dec, 2004'); | ||
self::assertInstanceOf(DateProp::class, $date); | ||
self::assertEquals(null, $date->getDay()); | ||
self::assertEquals(12, $date->getMonth()); | ||
self::assertEquals(2004, $date->getYear()); | ||
} | ||
} |
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 | ||
|
||
namespace JikanTest\Model\Common; | ||
|
||
use Jikan\Model\Common\DateProp; | ||
use Jikan\Model\Common\DateRange; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class DateRangeTest | ||
*/ | ||
class DateRangeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_gets_date() | ||
{ | ||
$date = new DateRange('Sep 15, 2018 to Sep, 2019'); | ||
self::assertInstanceOf(\DateTimeImmutable::class, $date->getFrom()); | ||
self::assertInstanceOf(\DateTimeImmutable::class, $date->getUntil()); | ||
|
||
$date = new DateRange('Sep 15, 2018 to ?'); | ||
self::assertInstanceOf(\DateTimeImmutable::class, $date->getFrom()); | ||
self::assertEquals(null, $date->getUntil()); | ||
|
||
$date = new DateRange('?'); | ||
self::assertEquals(null, $date->getFrom()); | ||
self::assertEquals(null, $date->getUntil()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_gets_date_props() | ||
{ | ||
$date = new DateRange('Sep 15, 2018 to Oct, 2019'); | ||
|
||
self::assertInstanceOf(DateProp::class, $date->getFromProp()); | ||
self::assertInstanceOf(DateProp::class, $date->getUntilProp()); | ||
|
||
self::assertEquals(15, $date->getFromProp()->getDay()); | ||
self::assertEquals(9, $date->getFromProp()->getMonth()); | ||
self::assertEquals(2018, $date->getFromProp()->getYear()); | ||
self::assertEquals(null, $date->getUntilProp()->getDay()); | ||
self::assertEquals(10, $date->getUntilProp()->getMonth()); | ||
self::assertEquals(2019, $date->getUntilProp()->getYear()); | ||
|
||
$date = new DateRange('Jan, 2018 to ?'); | ||
self::assertEquals(null, $date->getFromProp()->getDay()); | ||
self::assertEquals(1, $date->getFromProp()->getMonth()); | ||
self::assertEquals(2018, $date->getFromProp()->getYear()); | ||
self::assertEquals(null, $date->getUntilProp()->getDay()); | ||
self::assertEquals(null, $date->getUntilProp()->getMonth()); | ||
self::assertEquals(null, $date->getUntilProp()->getYear()); | ||
|
||
$date = new DateRange('?'); | ||
self::assertEquals(null, $date->getFromProp()->getDay()); | ||
self::assertEquals(null, $date->getFromProp()->getMonth()); | ||
self::assertEquals(null, $date->getFromProp()->getYear()); | ||
self::assertEquals(null, $date->getUntilProp()->getDay()); | ||
self::assertEquals(null, $date->getUntilProp()->getMonth()); | ||
self::assertEquals(null, $date->getUntilProp()->getYear()); | ||
|
||
$date = new DateRange('Jan 3, 2015 to 2016'); | ||
self::assertEquals(null, $date->getUntilProp()->getDay()); | ||
self::assertEquals(null, $date->getUntilProp()->getMonth()); | ||
self::assertEquals(2016, $date->getUntilProp()->getYear()); | ||
|
||
|
||
} | ||
} |