/
EventTest.php
75 lines (60 loc) · 1.78 KB
/
EventTest.php
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
70
71
72
73
74
75
<?php
namespace Botonomous;
use Botonomous\client\ApiClientTest;
use PHPUnit\Framework\TestCase;
/**
* Class EventTest.
*/
/** @noinspection PhpUndefinedClassInspection */
class EventTest extends TestCase
{
/**
* Test getBotId.
*/
public function testGetBotId()
{
$event = new Event('message');
$event->setBotId('B123');
$this->assertEquals('B123', $event->getBotId());
}
/**
* @throws \Exception
*/
public function testIsDirectMessageEmpty()
{
$event = new Event('message');
$this->assertEmpty($event->isDirectMessage());
}
/**
* Test isDirectMessageEmpty.
*/
public function testIsDirectMessage()
{
$event = new Event('message');
$event->setChannel('D024BE7RE');
$apiClientTest = new ApiClientTest();
$apiClient = $apiClientTest->getApiClient($this->getDummyImListResponse());
$event->setApiClient($apiClient);
$this->assertEquals(true, $event->isDirectMessage());
}
/**
* Test isDirectMessageEmpty.
*/
public function testIsNotDirectMessage()
{
$event = new Event('message');
$apiClientTest = new ApiClientTest();
$apiClient = $apiClientTest->getApiClient($this->getDummyImListResponse());
$event->setApiClient($apiClient);
$this->assertEmpty($event->isDirectMessage());
}
/**
* Return im list dummy response content.
*/
private function getDummyImListResponse()
{
return '{"ok": true, "ims":[{"id": "D024BFF1M", "is_im": true, "user": "USLACKBOT", "created": 1372105335,
"is_user_deleted": false }, { "id": "D024BE7RE", "is_im": true, "user": "U024BE7LH", "created": 1356250715,
"is_user_deleted": false}]}';
}
}