-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimelineTest.php
More file actions
56 lines (47 loc) · 1.62 KB
/
TimelineTest.php
File metadata and controls
56 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php declare(strict_types=1);
namespace Tests\Timer;
use PHPUnit\Framework\TestCase;
/**
* 测试 php-timer\Timer\Timeline
*
* @author fdipzone
*/
final class TimelineTest extends TestCase
{
/**
* @covers \Timer\Timeline::push
*/
public function testPush()
{
$millisecond_timestamp = time()*1000+100;
$content = 'event content1';
$event1 = new \Timer\Event($millisecond_timestamp, $content);
$millisecond_timestamp = time()*1000+200;
$content = 'event content2';
$event2 = new \Timer\Event($millisecond_timestamp, $content);
$timeline = new \Timer\Timeline;
$timeline->push($event1);
$timeline->push($event2);
$this->assertSame(2, count($timeline->events()));
}
/**
* @covers \Timer\Timeline::events
*/
public function testEvents()
{
$millisecond_timestamp1 = time()*1000+100;
$content1 = 'event content1';
$event1 = new \Timer\Event($millisecond_timestamp1, $content1);
$millisecond_timestamp2 = time()*1000+200;
$content2 = 'event content2';
$event2 = new \Timer\Event($millisecond_timestamp2, $content2);
$timeline = new \Timer\Timeline;
$timeline->push($event1);
$timeline->push($event2);
$events = $timeline->events();
$this->assertEquals($millisecond_timestamp1, $events[0]->millisecondTimestamp());
$this->assertEquals($content1, $events[0]->content());
$this->assertEquals($millisecond_timestamp2, $events[1]->millisecondTimestamp());
$this->assertEquals($content2, $events[1]->content());
}
}