|
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
|
|
|
use Gnello\OpenFireRestAPI\Utils\Debugger;
|
|
17
|
|
|
|
|
18
|
|
|
/**
|
|
19
|
|
|
* Class DebuggerTest
|
|
20
|
|
|
* @package Gnello\OpenFireRestAPI
|
|
21
|
|
|
*/
|
|
22
|
|
|
class DebuggerTest extends \PHPUnit_Framework_TestCase
|
|
23
|
|
|
{
|
|
24
|
|
|
/** @var Debugger */
|
|
25
|
|
|
protected $debugger;
|
|
26
|
|
|
|
|
27
|
|
|
protected function setUp()
|
|
28
|
|
|
{
|
|
29
|
|
|
$this->debugger = Debugger::getInstance();
|
|
30
|
|
|
}
|
|
31
|
|
|
|
|
32
|
|
|
protected function tearDown()
|
|
33
|
|
|
{
|
|
34
|
|
|
unset($this->debugger);
|
|
35
|
|
|
}
|
|
36
|
|
|
|
|
37
|
|
|
public function testGetInstance()
|
|
38
|
|
|
{
|
|
39
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Utils\\Debugger", $this->debugger);
|
|
40
|
|
|
}
|
|
41
|
|
|
|
|
42
|
|
|
public function testRecordRequest()
|
|
43
|
|
|
{
|
|
44
|
|
|
$this->debugger->recordRequest('url', 'headers', 'method', 'postData', 'response', 'server_output');
|
|
45
|
|
|
$expected = json_encode(array(array('url' => 'url', 'headers' => 'headers', 'method' => 'method', 'postData' => 'postData', 'response' => 'response', 'server_output' => 'server_output')));
|
|
46
|
|
|
$this->assertEquals($expected, json_encode($this->debugger->getRequests()));
|
|
47
|
|
|
}
|
|
48
|
|
|
|
|
49
|
|
|
public function testRecordCurlInfo()
|
|
50
|
|
|
{
|
|
51
|
|
|
$this->debugger->recordCurlInfo('test_curl');
|
|
52
|
|
|
$this->assertEquals('test_curl', $this->debugger->getCurlInfo());
|
|
53
|
|
|
}
|
|
54
|
|
|
} |