RequestResponseTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 45
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
B testSetGetValue() 0 25 1
A testUnregisteredKeyThrowsException() 0 7 1
1
<?php
2
3
namespace Onoi\HttpRequest\Tests;
4
5
use Onoi\HttpRequest\RequestResponse;
6
7
/**
8
 * @covers \Onoi\HttpRequest\RequestResponse
9
 * @group onoi-http-request
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.1
13
 *
14
 * @author mwjames
15
 */
16
class RequestResponseTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\Onoi\HttpRequest\RequestResponse',
22
			new RequestResponse()
23
		);
24
	}
25
26
	public function testSetGetValue() {
27
28
		$instance = new RequestResponse();
29
30
		$this->assertFalse(
31
			$instance->has( 'Foo' )
32
		);
33
34
		$instance->set( 'Foo', 42 );
35
36
		$this->assertEquals(
37
			42,
38
			$instance->get( 'Foo' )
39
		);
40
41
		$this->assertEquals(
42
			array( 'Foo' => 42 ),
43
			$instance->getList()
44
		);
45
46
		$this->assertInternalType(
47
			'string',
48
			$instance->asJsonString()
49
		);
50
	}
51
52
	public function testUnregisteredKeyThrowsException() {
53
54
		$instance = new RequestResponse();
55
56
		$this->setExpectedException( 'InvalidArgumentException' );
57
		$instance->get( 'Foo' );
58
	}
59
60
}
61