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

DocY10KTest::testRFC2550()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Popy\Calendar\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Popy\Calendar\Factory\ConfigurableFactory;
7
8
class DocY10KTest extends TestCase
9
{
10
    protected $factory;
11
    protected $calendar;
12
13
    public function setUp()
14
    {
15
        $this->factory = new ConfigurableFactory();
16
        $this->calendar = $this->factory->build([
17
            'number' => 'rfc2550',
18
            'additional_symbol_parser' => 'rfc2550',
19
        ]);
20
    }
21
22
    public function testRFC2550()
23
    {
24
        // Parsing a "normal" y40k date
25
        $date = $this->calendar->parse('40000', 'y');
26
27
        $this->assertInstanceOf('DateTimeinterface', $date);
28
        $this->assertEquals($date->format('Y'), '40000');
29
30
        // Now formatting it property :
31
        $this->assertEquals($this->calendar->format($date, 'y-m-d'), 'A40000-01-01');
32
33
        // Parsing a RFC2550 date :
34
        $date = $this->calendar->parse('A10000', 'y');
35
        $this->assertInstanceOf('DateTimeinterface', $date);
36
        $this->assertEquals($date->format('Y'), '10000');
37
    }
38
}
39