DateTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 31
ccs 18
cts 18
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testToNative() 0 4 1
A testEquals() 0 8 1
A testToString() 0 4 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/value-object project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\ValueObject;
10
11
use Daikon\ValueObject\Date;
12
use PHPUnit\Framework\TestCase;
13
14
final class DateTest extends TestCase
15
{
16
    private const DATE = '2016-07-04';
17
18
    private Date $date;
19
20 1
    public function testToNative(): void
21
    {
22 1
        $this->assertEquals(self::DATE, $this->date->toNative());
23 1
        $this->assertNull(Date::fromNative(null)->toNative());
24 1
    }
25
26 1
    public function testEquals(): void
27
    {
28 1
        $sameDate = Date::fromNative(self::DATE);
29 1
        $this->assertTrue($this->date->equals($sameDate));
30 1
        $sameDateOtherFormat = Date::fromString('2016-07-04T19:27:07', 'Y-m-d\\TH:i:s');
31 1
        $this->assertTrue($this->date->equals($sameDateOtherFormat));
32 1
        $differentDate = Date::fromNative('2017-08-10');
33 1
        $this->assertFalse($this->date->equals($differentDate));
34 1
    }
35
36 1
    public function testToString(): void
37
    {
38 1
        $this->assertEquals(self::DATE, (string)$this->date);
39 1
        $this->assertEquals('', (string)Date::fromNative(null));
40 1
    }
41
42 3
    protected function setUp(): void
43
    {
44 3
        $this->date = Date::fromNative(self::DATE);
45 3
    }
46
}
47