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

InfoTest::testCommandLicenseShorthand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class InfoTest 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\Info
20
	 */
21
	public function testNoConstructor()
22
	{
23
		$object = new \SwaggerGen\Swagger\Info;
24
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
25
26
		$this->assertSame(array(
27
			'title' => 'undefined',
28
			'version' => '0',
29
		), $object->toArray());
30
	}
31
32
	/**
33
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
34
	 */
35
	public function testCommandTitle()
36
	{
37
		$object = new \SwaggerGen\Swagger\Info;
38
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
39
40
		$object->handleCommand('title', 'This is the title');
41
42
		$this->assertSame(array(
43
			'title' => 'This is the title',
44
			'version' => '0',
45
				), $object->toArray());
46
	}
47
48
	/**
49
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
50
	 */
51
	public function testCommandDescription()
52
	{
53
		$object = new \SwaggerGen\Swagger\Info;
54
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
55
56
		$object->handleCommand('description', 'This is the description');
57
58
		$this->assertSame(array(
59
			'title' => 'undefined',
60
			'description' => 'This is the description',
61
			'version' => '0',
62
				), $object->toArray());
63
	}
64
65
	/**
66
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
67
	 */
68
	public function testCommandVersion()
69
	{
70
		$object = new \SwaggerGen\Swagger\Info;
71
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
72
73
		$object->handleCommand('version', '1.2.3a');
74
75
		$this->assertSame(array(
76
			'title' => 'undefined',
77
			'version' => '1.2.3a',
78
				), $object->toArray());
79
	}
80
81
	/**
82
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
83
	 */
84
	public function testCommandTermsofservice()
85
	{
86
		$object = new \SwaggerGen\Swagger\Info;
87
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
88
89
		$object->handleCommand('termsofservice', 'These are the terms');
90
91
		$this->assertSame(array(
92
			'title' => 'undefined',
93
			'termsOfService' => 'These are the terms',
94
			'version' => '0',
95
				), $object->toArray());
96
	}
97
98
	/**
99
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
100
	 */
101
	public function testCommandTerms()
102
	{
103
		$object = new \SwaggerGen\Swagger\Info;
104
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
105
106
		$object->handleCommand('terms', 'These are the terms');
107
108
		$this->assertSame(array(
109
			'title' => 'undefined',
110
			'termsOfService' => 'These are the terms',
111
			'version' => '0',
112
				), $object->toArray());
113
	}
114
115
	/**
116
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
117
	 */
118
	public function testCommandContactNameUrlEmail()
119
	{
120
		$object = new \SwaggerGen\Swagger\Info;
121
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
122
123
		$object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]');
124
125
		$this->assertSame(array(
126
			'title' => 'undefined',
127
			'contact' => array(
128
				'name' => 'Arthur D. Author',
129
				'url' => 'http://example.test',
130
				'email' => '[email protected]',
131
			),
132
			'version' => '0',
133
				), $object->toArray());
134
	}
135
136
	/**
137
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
138
	 */
139
	public function testCommandContactNameEmailNameUrlName()
140
	{
141
		$object = new \SwaggerGen\Swagger\Info;
142
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
143
144
		$object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author    ');
145
146
		$this->assertSame(array(
147
			'title' => 'undefined',
148
			'contact' => array(
149
				'name' => 'Arthur D. Author',
150
				'url' => 'http://example.test',
151
				'email' => '[email protected]',
152
			),
153
			'version' => '0',
154
				), $object->toArray());
155
	}
156
157
	/**
158
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
159
	 */
160
	public function testCommandLicenseNameUrl()
161
	{
162
		$object = new \SwaggerGen\Swagger\Info;
163
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
164
165
		$object->handleCommand('license', 'NAME http://example.test');
166
167
		$this->assertSame(array(
168
			'title' => 'undefined',
169
			'license' => array(
170
				'name' => 'NAME',
171
				'url' => 'http://example.test',
172
			),
173
			'version' => '0',
174
				), $object->toArray());
175
	}
176
177
	/**
178
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
179
	 */
180
	public function testCommandLicenseUrlName()
181
	{
182
		$object = new \SwaggerGen\Swagger\Info;
183
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
184
185
		$object->handleCommand('license', 'http://example.test NAME');
186
187
		$this->assertSame(array(
188
			'title' => 'undefined',
189
			'license' => array(
190
				'name' => 'NAME',
191
				'url' => 'http://example.test',
192
			),
193
			'version' => '0',
194
				), $object->toArray());
195
	}
196
197
	/**
198
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
199
	 */
200
	public function testCommandLicenseShorthand()
201
	{
202
		$object = new \SwaggerGen\Swagger\Info;
203
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
204
205
		$object->handleCommand('license', 'BSD');
206
207
		$this->assertSame(array(
208
			'title' => 'undefined',
209
			'license' => array(
210
				'name' => 'BSD',
211
				'url' => 'https://opensource.org/licenses/BSD-2-Clause',
212
			),
213
			'version' => '0',
214
				), $object->toArray());
215
	}
216
217
	/**
218
	 * @covers \SwaggerGen\Swagger\Info::handleCommand
219
	 */
220
	public function testCommandAll()
221
	{
222
		$object = new \SwaggerGen\Swagger\Info;
223
		$this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object);
224
225
		$object->handleCommand('description', 'This is the description');
226
		$object->handleCommand('license', 'BSD');
227
		$object->handleCommand('terms', 'These are the terms');
228
		$object->handleCommand('version', '1.2.3a');
229
		$object->handleCommand('title', 'This is the title');
230
		$object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]');
231
232
		$this->assertSame(array(
233
			'title' => 'This is the title',
234
			'description' => 'This is the description',
235
			'termsOfService' => 'These are the terms',
236
			'contact' => array(
237
				'name' => 'Arthur D. Author',
238
				'url' => 'http://example.test',
239
				'email' => '[email protected]',
240
			),
241
			'license' => array(
242
				'name' => 'BSD',
243
				'url' => 'https://opensource.org/licenses/BSD-2-Clause',
244
			),
245
			'version' => '1.2.3a',
246
				), $object->toArray());
247
	}
248
249
}
250