|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Graze\DogStatsD\Test\Unit; |
|
4
|
|
|
|
|
5
|
|
|
use Graze\DogStatsD\Client; |
|
6
|
|
|
use Graze\DogStatsD\Test\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
class EventTest extends TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
public function testSimpleEvent() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->client->event('some_title', 'textAndThings'); |
|
13
|
|
|
$this->assertEquals('_e{10,13}:some_title|textAndThings', $this->client->getLastMessage()); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function testEventMetadata() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->client->event( |
|
19
|
|
|
'some_title', |
|
20
|
|
|
'textAndThings', |
|
21
|
|
|
[ |
|
22
|
|
|
'time' => 12345678, |
|
23
|
|
|
'hostname' => 'some.host', |
|
24
|
|
|
'key' => 'someKey', |
|
25
|
|
|
'priority' => Client::PRIORITY_LOW, |
|
26
|
|
|
'source' => 'space', |
|
27
|
|
|
'alert' => Client::ALERT_INFO, |
|
28
|
|
|
] |
|
29
|
|
|
); |
|
30
|
|
|
$this->assertEquals( |
|
31
|
|
|
'_e{10,13}:some_title|textAndThings|d:12345678|h:some.host|k:someKey|p:low|s:space|t:info', |
|
32
|
|
|
$this->client->getLastMessage() |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testEventTags() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->client->event( |
|
39
|
|
|
'some_title', |
|
40
|
|
|
'textAndThings', |
|
41
|
|
|
[ |
|
42
|
|
|
'time' => 12345678, |
|
43
|
|
|
], |
|
44
|
|
|
['tag'] |
|
45
|
|
|
); |
|
46
|
|
|
$this->assertEquals( |
|
47
|
|
|
'_e{10,13}:some_title|textAndThings|d:12345678|#tag', |
|
48
|
|
|
$this->client->getLastMessage() |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testEventTextReplacesNewLines() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->client->event('some_title', "LongText\rAnd\nStuff"); |
|
55
|
|
|
$this->assertEquals("_e{10,18}:some_title|LongTextAnd\\nStuff", $this->client->getLastMessage()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testCoreStatsDImplementation() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->client->configure(array( |
|
61
|
|
|
'host' => '127.0.0.1', |
|
62
|
|
|
'port' => 8125, |
|
63
|
|
|
'dataDog' => false |
|
64
|
|
|
)); |
|
65
|
|
|
$this->client->event('some_title', 'textAndThings'); |
|
66
|
|
|
$this->assertEquals('', $this->client->getLastMessage()); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|