Passed
Push — master ( 8a4be9...c7b6b7 )
by Pierre
09:51
created

ReadmeTest::testPresetFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Popy\Calendar\Tests;
4
5
use DateTime;
6
use PHPUnit\Framework\TestCase;
7
use Popy\Calendar\PresetParser;
8
use Popy\Calendar\PresetFormatter;
9
use Popy\Calendar\Calendar\GregorianCalendar;
10
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