|
1
|
|
|
<?php
|
|
2
|
|
|
/**
|
|
3
|
|
|
* OpenFireRestAPI is based entirely on official documentation of the REST API
|
|
4
|
|
|
* Plugin and you can extend it by following the directives of the documentation
|
|
5
|
|
|
*
|
|
6
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
7
|
|
|
* file that was distributed with this source code. For the full list of
|
|
8
|
|
|
* contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
|
|
9
|
|
|
*
|
|
10
|
|
|
* @author Luca Agnello <[email protected]>
|
|
11
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
|
|
12
|
|
|
*/
|
|
13
|
|
|
|
|
14
|
|
|
namespace Gnello\OpenFireRestAPI;
|
|
15
|
|
|
|
|
16
|
|
|
/**
|
|
17
|
|
|
* Class APITest
|
|
18
|
|
|
* @package Gnello\OpenFireRestAPI
|
|
19
|
|
|
*/
|
|
20
|
|
|
class APITest extends \PHPUnit_Framework_TestCase
|
|
21
|
|
|
{
|
|
22
|
|
|
/** @var AuthenticationToken */
|
|
23
|
|
|
protected $authenticationToken;
|
|
24
|
|
|
|
|
25
|
|
|
/** @var API */
|
|
26
|
|
|
protected $api;
|
|
27
|
|
|
|
|
28
|
|
|
protected function setUp()
|
|
29
|
|
|
{
|
|
30
|
|
|
$this->authenticationToken = new AuthenticationToken('shared_secret_key');
|
|
31
|
|
|
$this->api = new API('http://host', 9090, $this->authenticationToken);
|
|
32
|
|
|
}
|
|
33
|
|
|
|
|
34
|
|
|
protected function tearDown()
|
|
35
|
|
|
{
|
|
36
|
|
|
$this->api = null;
|
|
37
|
|
|
}
|
|
38
|
|
|
|
|
39
|
|
|
public function testAPISettings()
|
|
40
|
|
|
{
|
|
41
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Settings\\Settings", $this->api->Settings());
|
|
42
|
|
|
}
|
|
43
|
|
|
|
|
44
|
|
|
public function testAPISettingsGetHost()
|
|
45
|
|
|
{
|
|
46
|
|
|
$this->assertEquals("host", $this->api->Settings()->getHost());
|
|
47
|
|
|
}
|
|
48
|
|
|
|
|
49
|
|
|
public function testAPISettingsGetPort()
|
|
50
|
|
|
{
|
|
51
|
|
|
$this->assertEquals(9090, $this->api->Settings()->getPort());
|
|
52
|
|
|
}
|
|
53
|
|
|
|
|
54
|
|
|
public function testAPISettingsGetServerName()
|
|
55
|
|
|
{
|
|
56
|
|
|
$this->assertEquals("host", $this->api->Settings()->getServerName());
|
|
57
|
|
|
}
|
|
58
|
|
|
|
|
59
|
|
|
public function testAPIisSSL()
|
|
60
|
|
|
{
|
|
61
|
|
|
$api = new API('https://host', 9090, $this->authenticationToken);
|
|
62
|
|
|
$this->assertTrue($api->Settings()->isSSL());
|
|
63
|
|
|
}
|
|
64
|
|
|
|
|
65
|
|
|
public function testAPIisSSLNot()
|
|
66
|
|
|
{
|
|
67
|
|
|
$api = new API('http://host', 9090, $this->authenticationToken);
|
|
68
|
|
|
$this->assertFalse($api->Settings()->isSSL());
|
|
69
|
|
|
}
|
|
70
|
|
|
|
|
71
|
|
|
public function testAPIUsers()
|
|
72
|
|
|
{
|
|
73
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\UserEndpoint", $this->api->Users());
|
|
74
|
|
|
}
|
|
75
|
|
|
|
|
76
|
|
|
public function testAPIChatRooms()
|
|
77
|
|
|
{
|
|
78
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\ChatRoomEndpoint", $this->api->ChatRooms());
|
|
79
|
|
|
}
|
|
80
|
|
|
|
|
81
|
|
|
public function testAPIGroups()
|
|
82
|
|
|
{
|
|
83
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\GroupEndpoint", $this->api->Groups());
|
|
84
|
|
|
}
|
|
85
|
|
|
|
|
86
|
|
|
public function testAPIMessages()
|
|
87
|
|
|
{
|
|
88
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\MessageEndpoint", $this->api->Messages());
|
|
89
|
|
|
}
|
|
90
|
|
|
|
|
91
|
|
|
public function testAPISessions()
|
|
92
|
|
|
{
|
|
93
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\SessionEndpoint", $this->api->Sessions());
|
|
94
|
|
|
}
|
|
95
|
|
|
|
|
96
|
|
|
public function testAPISystem()
|
|
97
|
|
|
{
|
|
98
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Endpoints\\SystemEndpoint", $this->api->System());
|
|
99
|
|
|
}
|
|
100
|
|
|
|
|
101
|
|
|
public function testAPIPayloads()
|
|
102
|
|
|
{
|
|
103
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Payloads\\Payload", $this->api->Payloads());
|
|
104
|
|
|
}
|
|
105
|
|
|
|
|
106
|
|
|
public function testAPIDebugger()
|
|
107
|
|
|
{
|
|
108
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Utils\\Debugger", $this->api->Debugger());
|
|
109
|
|
|
}
|
|
110
|
|
|
} |