DateTest::testEquals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
c 1
b 0
f 0
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