-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventTest.php
More file actions
69 lines (63 loc) · 1.97 KB
/
EventTest.php
File metadata and controls
69 lines (63 loc) · 1.97 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
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php declare(strict_types=1);
namespace Tests\Timer;
use PHPUnit\Framework\TestCase;
/**
* 测试 php-timer\Timer\Event
*
* @author fdipzone
*/
final class EventTest extends TestCase
{
/**
* @covers \Timer\Event::__construct
*/
public function testConstruct()
{
$millisecond_timestamp = time()*1000+mt_rand(100,999);
$content = 'event content';
$event = new \Timer\Event($millisecond_timestamp, $content);
$this->assertEquals('Timer\Event', get_class($event));
}
/**
* @covers \Timer\Event::__construct
*/
public function testConstructTimestampException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('timer event: millisecond timestamp invalid');
$millisecond_timestamp = 0;
$content = 'event content';
new \Timer\Event($millisecond_timestamp, $content);
}
/**
* @covers \Timer\Event::__construct
*/
public function testConstructContentException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('timer event: content is empty');
$millisecond_timestamp = time()*1000+mt_rand(100,999);
$content = '';
new \Timer\Event($millisecond_timestamp, $content);
}
/**
* @covers \Timer\Event::millisecondTimestamp
*/
public function testMillisecondTimestamp()
{
$millisecond_timestamp = time()*1000+mt_rand(100,999);
$content = 'event content';
$event = new \Timer\Event($millisecond_timestamp, $content);
$this->assertEquals($millisecond_timestamp, $event->millisecondTimestamp());
}
/**
* @covers \Timer\Event::content
*/
public function testContent()
{
$millisecond_timestamp = time()*1000+mt_rand(100,999);
$content = 'event content';
$event = new \Timer\Event($millisecond_timestamp, $content);
$this->assertEquals($content, $event->content());
}
}