DateMapTest::testToString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
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\Tests\ValueObject\Fixture\DateMap;
12
use Daikon\ValueObject\Date;
13
use PHPUnit\Framework\TestCase;
14
15
final class DateMapTest extends TestCase
16
{
17 1
    public function testConstruct(): void
18
    {
19 1
        $d0 = Date::fromString('2020-01-01');
20 1
        $unwrappedMap = (new DateMap(['a' => $d0]))->unwrap();
21 1
        $this->assertNotSame($d0, $unwrappedMap['a']);
22 1
        $this->assertEquals($d0, $unwrappedMap['a']);
23 1
    }
24
25 1
    public function testFromNative(): void
26
    {
27 1
        $unwrappedMap = DateMap::fromNative(['a' => '2020-01-01'])->unwrap();
28 1
        $this->assertCount(1, $unwrappedMap);
29 1
        $this->assertInstanceOf(Date::class, $unwrappedMap['a']);
30 1
    }
31
32 1
    public function testEquals(): void
33
    {
34 1
        $d0 = Date::fromString('2020-01-01');
35 1
        $map0 = new DateMap(['a' => $d0]);
36 1
        $map1 = new DateMap(['a' => $d0]);
37 1
        $this->assertTrue($map0->equals($map1));
38 1
        $this->assertNotSame($map0, $map1);
39 1
        $this->assertEquals($map0, $map1);
40 1
    }
41
42 1
    public function testNotEquals(): void
43
    {
44 1
        $d0 = Date::fromString('2020-01-01');
45 1
        $d1 = Date::fromString('2030-01-01');
46 1
        $map0 = new DateMap(['a' => $d0, 'b' => $d1]);
47 1
        $map1 = new DateMap(['a' => $d1, 'b' => $d0]);
48 1
        $this->assertFalse($map0->equals($map1));
49 1
        $this->assertNotSame($map0, $map1);
50 1
    }
51
52 1
    public function testToString(): void
53
    {
54 1
        $d0 = Date::fromString('2020-01-01');
55 1
        $d1 = Date::fromString('2030-01-01');
56 1
        $map = new DateMap(['a' => $d0, 'b' => $d1]);
57 1
        $this->assertEquals('a:2020-01-01, b:2030-01-01', (string)$map);
58 1
    }
59
}
60