Completed
Push — master ( 3853ec...f78c46 )
by Adrien
07:49
created

DateTypeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testTimezoneIsIgnored() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApplicationTest\Api\Scalar;
6
7
use Application\Api\Scalar\DateType;
8
use Cake\Chronos\Date;
9
use PHPUnit\Framework\TestCase;
10
11
class DateTypeTest extends TestCase
12
{
13
    public function testTimezoneIsIgnored(): void
14
    {
15
        $type = new DateType();
16
        $actual = $type->parseValue('2010-02-09');
17
        self::assertInstanceOf(Date::class, $actual);
18
        self::assertSame('2010-02-09T00:00:00+00:00', $actual->format('c'));
19
20
        $actual = $type->parseValue('2010-02-09T23:00:00');
21
        self::assertInstanceOf(Date::class, $actual);
22
        self::assertSame('2010-02-09T00:00:00+00:00', $actual->format('c'));
23
24
        $actual = $type->parseValue('2010-02-09T02:00:00+08:00');
25
        self::assertInstanceOf(Date::class, $actual);
26
        self::assertSame('2010-02-09T00:00:00+00:00', $actual->format('c'), 'timezone should be ignored');
27
28
        $date = new Date('2010-02-03');
29
        $actual = $type->serialize($date);
30
        self::assertSame('2010-02-03', $actual);
31
    }
32
}
33