Completed
Push — master ( 0768ef...ea365c )
by Luca
03:38
created

DebuggerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A tearDown() 0 4 1
A testGetInstance() 0 4 1
A testRecordRequest() 0 6 1
A testRecordCurlInfo() 0 5 1
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
}