Completed
Push — master ( 088bf6...a47832 )
by Martijn
02:41
created

LicenseTest::testCommandName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class LicenseTest extends SwaggerGen_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
	protected $parent;
7
8
	protected function setUp()
9
	{
10
		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
	}
12
13
	protected function assertPreConditions()
14
	{
15
		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
	}
17
18
	/**
19
	 * @covers \SwaggerGen\Swagger\License::__construct
20
	 * @covers \SwaggerGen\Swagger\License::toArray
21
	 */
22
	public function testConstructor2Unknown()
23
	{
24
		$object = new \SwaggerGen\Swagger\License($this->parent, 'Name');
25
26
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
27
28
		$this->assertSame(array(
29
			'name' => 'Name',
30
				), $object->toArray());
31
	}
32
33
	/**
34
	 * @covers \SwaggerGen\Swagger\License::__construct
35
	 * @covers \SwaggerGen\Swagger\License::toArray
36
	 */
37
	public function testConstructor2Known()
38
	{
39
		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
40
41
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
42
43
		$this->assertSame(array(
44
			'name' => 'MIT',
45
			'url' => 'http://opensource.org/licenses/MIT',
46
				), $object->toArray());
47
	}
48
49
	/**
50
	 * @covers \SwaggerGen\Swagger\License::__construct
51
	 * @covers \SwaggerGen\Swagger\License::toArray
52
	 */
53
	public function testConstructor3Unknown()
54
	{
55
		$object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example');
56
57
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
58
59
		$this->assertSame(array(
60
			'name' => 'Name',
61
			'url' => 'http://example',
62
				), $object->toArray());
63
	}
64
65
	/**
66
	 * @covers \SwaggerGen\Swagger\License::__construct
67
	 * @covers \SwaggerGen\Swagger\License::toArray
68
	 */
69
	public function testConstructor3Known()
70
	{
71
		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example');
72
73
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
74
75
		$this->assertSame(array(
76
			'name' => 'MIT',
77
			'url' => 'http://example',
78
				), $object->toArray());
79
	}
80
81
	/**
82
	 * @covers \SwaggerGen\Swagger\Tag::handleCommand
83
	 */
84
	public function testCommandName()
85
	{
86
		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
87
88
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
89
90
		$object->handleCommand('name', 'GPL-3');
91
92
		$this->assertSame(array(
93
			'name' => 'GPL-3',
94
			'url' => 'http://opensource.org/licenses/MIT',
95
				), $object->toArray());
96
	}
97
98
	/**
99
	 * @covers \SwaggerGen\Swagger\Tag::handleCommand
100
	 */
101
	public function testCommandUrl()
102
	{
103
		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
104
105
		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
106
107
		$object->handleCommand('url', 'http://example');
108
109
		$this->assertSame(array(
110
			'name' => 'MIT',
111
			'url' => 'http://example',
112
				), $object->toArray());
113
	}
114
115
}
116