Completed
Push — master ( 70f8a5...37b9af )
by Frank
02:03
created

PointInTimeTest::creating_from_string()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace EventSauce\EventSourcing;
4
5
use DateTimeImmutable;
6
use InvalidArgumentException;
7
use PHPUnit\Framework\TestCase;
8
9
class PointInTimeTest extends TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function creating_from_string()
15
    {
16
        $pointInTime = PointInTime::fromString('2017-01-01 10:30:00.000000+0000');
17
        $this->assertEquals('2017-01-01 10:30:00.000000+0000', $pointInTime->toString());
18
        $this->assertEquals('2017-01-01 10:30:00.000000+0000', (string) $pointInTime);
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function creating_from_invalid_input()
25
    {
26
        $this->expectException(InvalidArgumentException::class);
27
        PointInTime::fromString('this is invalid');
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function creating_from_date_time()
34
    {
35
        $dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s.uO', '2017-01-01 10:30:00.000000+0000');
36
        $pointInTime = PointInTime::fromDateTime($dateTime);
37
        $this->assertEquals($dateTime, $pointInTime->dateTime());
38
    }
39
}