RequestResponseTest::testSetGetValue()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 25
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
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