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

TestClockTest::creating_points_in_time()   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\Time;
4
5
use EventSauce\EventSourcing\PointInTime;
6
use PHPUnit\Framework\TestCase;
7
8
class TestClockTest extends TestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function getting_back_equal_date_times()
14
    {
15
        $clock = new TestClock();
16
        $d1 = $clock->dateTime();
17
        $d2 = $clock->dateTime();
18
        $this->assertEquals($d1, $d2);
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function ticking_the_clock_sets_it_forward()
25
    {
26
        $clock = new TestClock();
27
        $d1 = $clock->dateTime();
28
        $clock->tick();
29
        $d2 = $clock->dateTime();
30
        $this->assertNotEquals($d1, $d2);
31
        $this->assertTrue($d1 < $d2);
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function fixating_the_clock()
38
    {
39
        $clock = new TestClock();
40
        $clock->fixate('2017-01-01 12:00:00');
41
        $d1 = $clock->dateTime();
42
        $clock->fixate('2016-01-01 12:00:00');
43
        $d2 = $clock->dateTime();
44
        $this->assertTrue($d1 > $d2);
45
    }
46
47
    /**
48
     * @test
49
     */
50
    public function creating_points_in_time()
51
    {
52
        $clock = new TestClock();
53
        $pointInTime = $clock->pointInTime();
54
        $this->assertInstanceOf(PointInTime::class, $pointInTime);
55
    }
56
}