| 1 | <?php |
||
| 11 | class ReadmeTest extends TestCase |
||
| 12 | { |
||
| 13 | protected $calendar; |
||
| 14 | |||
| 15 | public function setUp() { |
||
| 16 | $this->calendar = new GregorianCalendar(); |
||
| 17 | } |
||
| 18 | |||
| 19 | public function testUseGregorianCalendarFormat() { |
||
| 20 | $this->assertEquals( |
||
| 21 | $this->calendar->format(new DateTime(), 'Y-m-d'), |
||
| 22 | date('Y-m-d') |
||
| 23 | ); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function testUseGregorianCalendarParse() { |
||
| 27 | $parseResult = $this->calendar->parse('2000-01-01', 'Y-m-d'); |
||
| 28 | |||
| 29 | $this->assertEquals( |
||
| 30 | $parseResult->format('Y-m-d'), |
||
| 31 | '2000-01-01' |
||
| 32 | ); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function testPresetFormatter() { |
||
| 36 | $formatter = new PresetFormatter( |
||
| 37 | $this->calendar, |
||
| 38 | 'Y-m-d' |
||
| 39 | ); |
||
| 40 | |||
| 41 | $this->assertEquals( |
||
| 42 | $formatter->format(new DateTime()), |
||
| 43 | date('Y-m-d') |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function testPresetParser() { |
||
| 48 | $parser = new PresetParser($this->calendar, 'Y-m-d'); |
||
| 49 | $parseResult = $parser->parse('2017-05-01'); |
||
| 50 | |||
| 51 | $this->assertEquals( |
||
| 52 | $parseResult->format('Y-m-d'), |
||
| 53 | '2017-05-01' |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |