Completed
Push — master ( 178f75...a30e65 )
by Scott Kingsley
03:43
created
tests/test-wp-fields-api.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 		global $wp_fields;
22 22
 
23 23
 		// Reset WP Fields instance for testing purposes
24
-		$wp_fields->remove_form( true, true );
25
-		$wp_fields->remove_section( true, true );
26
-		$wp_fields->remove_field( true, true );
27
-		$wp_fields->remove_control( true, true );
24
+		$wp_fields->remove_form(true, true);
25
+		$wp_fields->remove_section(true, true);
26
+		$wp_fields->remove_field(true, true);
27
+		$wp_fields->remove_control(true, true);
28 28
 
29 29
 	}
30 30
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		 */
41 41
 		global $wp_fields;
42 42
 
43
-		$this->assertTrue( is_a( $wp_fields, 'WP_Fields_API' ) );
43
+		$this->assertTrue(is_a($wp_fields, 'WP_Fields_API'));
44 44
 
45 45
 	}
46 46
 
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @param string $object_type
51 51
 	 * @param string $object_name
52 52
 	 */
53
-	public function test_add_form( $object_type = 'post', $object_name = null ) {
53
+	public function test_add_form($object_type = 'post', $object_name = null) {
54 54
 
55 55
 		/**
56 56
 		 * @var $wp_fields WP_Fields_API
57 57
 		 */
58 58
 		global $wp_fields;
59 59
 
60
-		$wp_fields->add_form( $object_type, 'my_test_form', $object_name );
60
+		$wp_fields->add_form($object_type, 'my_test_form', $object_name);
61 61
 
62 62
 	}
63 63
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 * @param string $object_type
68 68
 	 * @param string $object_name
69 69
 	 */
70
-	public function test_add_form_invalid( $object_type = 'post' ) {
70
+	public function test_add_form_invalid($object_type = 'post') {
71 71
 
72 72
 		/**
73 73
 		 * @var $wp_fields WP_Fields_API
74 74
 		 */
75 75
 		global $wp_fields;
76 76
 
77
-		$wp_fields->add_form( $object_type, null, null, array() );
77
+		$wp_fields->add_form($object_type, null, null, array());
78 78
 
79 79
 	}
80 80
 
@@ -89,37 +89,37 @@  discard block
 block discarded – undo
89 89
 		global $wp_fields;
90 90
 
91 91
 		// Add a form
92
-		$this->test_add_form( $this->object_type, $this->object_name );
92
+		$this->test_add_form($this->object_type, $this->object_name);
93 93
 
94 94
 		// Get forms for object type / name
95
-		$forms = $wp_fields->get_forms( $this->object_type, $this->object_name );
95
+		$forms = $wp_fields->get_forms($this->object_type, $this->object_name);
96 96
 
97
-		$this->assertEquals( 1, count( $forms ) );
97
+		$this->assertEquals(1, count($forms));
98 98
 
99
-		$this->assertArrayHasKey( 'my_test_form', $forms );
99
+		$this->assertArrayHasKey('my_test_form', $forms);
100 100
 
101 101
 		// Get a form that doesn't exist
102
-		$forms = $wp_fields->get_forms( $this->object_type, 'some_other_post_type' );
102
+		$forms = $wp_fields->get_forms($this->object_type, 'some_other_post_type');
103 103
 
104
-		$this->assertEquals( 0, count( $forms ) );
104
+		$this->assertEquals(0, count($forms));
105 105
 
106 106
 		// Get all forms for object type
107
-		$forms = $wp_fields->get_forms( $this->object_type, true );
107
+		$forms = $wp_fields->get_forms($this->object_type, true);
108 108
 
109
-		$this->assertEquals( 1, count( $forms ) );
109
+		$this->assertEquals(1, count($forms));
110 110
 
111
-		$form_ids = wp_list_pluck( $forms, 'id' );
111
+		$form_ids = wp_list_pluck($forms, 'id');
112 112
 
113
-		$this->assertContains( 'my_test_form', $form_ids );
113
+		$this->assertContains('my_test_form', $form_ids);
114 114
 
115 115
 		// Get all forms for all object types
116 116
 		$forms = $wp_fields->get_forms();
117 117
 
118 118
 		// Each array item is an object type with an array of object names
119
-		$this->assertEquals( 1, count( $forms ) );
119
+		$this->assertEquals(1, count($forms));
120 120
 
121 121
 		// Array keys are object types
122
-		$this->assertArrayHasKey( $this->object_type, $forms );
122
+		$this->assertArrayHasKey($this->object_type, $forms);
123 123
 
124 124
 	}
125 125
 
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 		global $wp_fields;
135 135
 
136 136
 		// Add a form
137
-		$this->test_add_form( $this->object_type );
137
+		$this->test_add_form($this->object_type);
138 138
 
139 139
 		// Get forms for object type / name
140
-		$forms = $wp_fields->get_forms( $this->object_type );
140
+		$forms = $wp_fields->get_forms($this->object_type);
141 141
 
142
-		$this->assertEquals( 1, count( $forms ) );
142
+		$this->assertEquals(1, count($forms));
143 143
 
144
-		$this->assertArrayHasKey( 'my_test_form', $forms );
144
+		$this->assertArrayHasKey('my_test_form', $forms);
145 145
 
146 146
 	}
147 147
 
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
 		global $wp_fields;
157 157
 
158 158
 		// Add a form
159
-		$this->test_add_form( $this->object_type, $this->object_name );
159
+		$this->test_add_form($this->object_type, $this->object_name);
160 160
 
161 161
 		// Form exists for this object type / name
162
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
162
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
163 163
 
164
-		$this->assertNotEmpty( $form );
164
+		$this->assertNotEmpty($form);
165 165
 
166
-		$this->assertEquals( 'my_test_form', $form->id );
166
+		$this->assertEquals('my_test_form', $form->id);
167 167
 
168 168
 		// Form doesn't exist for this object type / name
169
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form1' );
169
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form1');
170 170
 
171
-		$this->assertEmpty( $form );
171
+		$this->assertEmpty($form);
172 172
 
173 173
 		// Form doesn't exist for this object type / name
174
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form2', $this->object_name );
174
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form2', $this->object_name);
175 175
 
176
-		$this->assertEmpty( $form );
176
+		$this->assertEmpty($form);
177 177
 
178 178
 	}
179 179
 
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
 		global $wp_fields;
189 189
 
190 190
 		// Add a form
191
-		$this->test_add_form( $this->object_type, $this->object_name );
191
+		$this->test_add_form($this->object_type, $this->object_name);
192 192
 
193 193
 		// Form exists for this object type / name
194
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
194
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
195 195
 
196
-		$this->assertNotEmpty( $form );
196
+		$this->assertNotEmpty($form);
197 197
 
198
-		$this->assertEquals( 'my_test_form', $form->id );
198
+		$this->assertEquals('my_test_form', $form->id);
199 199
 
200 200
 		// Remove form
201
-		$wp_fields->remove_form( $this->object_type, 'my_test_form', $this->object_name );
201
+		$wp_fields->remove_form($this->object_type, 'my_test_form', $this->object_name);
202 202
 
203 203
 		// Form no longer exists for this object type / name
204
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
204
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
205 205
 
206
-		$this->assertEmpty( $form );
206
+		$this->assertEmpty($form);
207 207
 
208 208
 	}
209 209
 
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
 		global $wp_fields;
219 219
 
220 220
 		// Add a form
221
-		$this->test_add_form( $this->object_type, $this->object_name );
221
+		$this->test_add_form($this->object_type, $this->object_name);
222 222
 
223 223
 		// Remove form
224
-		$wp_fields->remove_form( $this->object_type, null, true );
224
+		$wp_fields->remove_form($this->object_type, null, true);
225 225
 
226 226
 		// Form no longer exists for this object type / name
227
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
227
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
228 228
 
229
-		$this->assertEmpty( $form );
229
+		$this->assertEmpty($form);
230 230
 
231 231
 	}
232 232
 
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		global $wp_fields;
242 242
 
243 243
 		// Add a form
244
-		$this->test_add_form( $this->object_type );
244
+		$this->test_add_form($this->object_type);
245 245
 
246 246
 		// Remove form
247
-		$wp_fields->remove_form( $this->object_type, 'my_test_form' );
247
+		$wp_fields->remove_form($this->object_type, 'my_test_form');
248 248
 
249 249
 		// Form no longer exists for this object type / name
250
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form' );
250
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form');
251 251
 
252
-		$this->assertEmpty( $form );
252
+		$this->assertEmpty($form);
253 253
 
254 254
 	}
255 255
 
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
 		global $wp_fields;
265 265
 
266 266
 		// Add a form
267
-		$this->test_add_form( $this->object_type, $this->object_name );
267
+		$this->test_add_form($this->object_type, $this->object_name);
268 268
 
269 269
 		// Remove form
270
-		$wp_fields->remove_form( $this->object_type, true, $this->object_name );
270
+		$wp_fields->remove_form($this->object_type, true, $this->object_name);
271 271
 
272 272
 		// Form no longer exists for this object type / name
273
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
273
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
274 274
 
275
-		$this->assertEmpty( $form );
275
+		$this->assertEmpty($form);
276 276
 
277 277
 	}
278 278
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param string $object_type
283 283
 	 * @param string $object_name
284 284
 	 */
285
-	public function test_add_section( $object_type = 'post', $object_name = null ) {
285
+	public function test_add_section($object_type = 'post', $object_name = null) {
286 286
 
287 287
 		/**
288 288
 		 * @var $wp_fields WP_Fields_API
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 		global $wp_fields;
291 291
 
292 292
 		// Add a form
293
-		$this->test_add_form( $object_type, $object_name );
293
+		$this->test_add_form($object_type, $object_name);
294 294
 
295
-		$wp_fields->add_section( $object_type, 'my_test_section', $object_name, array(
295
+		$wp_fields->add_section($object_type, 'my_test_section', $object_name, array(
296 296
 			'form' => 'my_test_form',
297
-		) );
297
+		));
298 298
 
299 299
 	}
300 300
 
@@ -309,56 +309,56 @@  discard block
 block discarded – undo
309 309
 		global $wp_fields;
310 310
 
311 311
 		// Add a form
312
-		$this->test_add_section( $this->object_type, $this->object_name );
312
+		$this->test_add_section($this->object_type, $this->object_name);
313 313
 
314 314
 		// Get sections for object type / name
315
-		$sections = $wp_fields->get_sections( $this->object_type, $this->object_name );
315
+		$sections = $wp_fields->get_sections($this->object_type, $this->object_name);
316 316
 
317
-		$this->assertEquals( 1, count( $sections ) );
317
+		$this->assertEquals(1, count($sections));
318 318
 
319
-		$this->assertArrayHasKey( 'my_test_section', $sections );
319
+		$this->assertArrayHasKey('my_test_section', $sections);
320 320
 
321 321
 		// Get a section that doesn't exist
322
-		$sections = $wp_fields->get_sections( $this->object_type, 'some_other_post_type' );
322
+		$sections = $wp_fields->get_sections($this->object_type, 'some_other_post_type');
323 323
 
324
-		$this->assertEquals( 0, count( $sections ) );
324
+		$this->assertEquals(0, count($sections));
325 325
 
326 326
 		// Get sections by form
327
-		$sections = $wp_fields->get_sections( $this->object_type, $this->object_name, 'my_test_form' );
327
+		$sections = $wp_fields->get_sections($this->object_type, $this->object_name, 'my_test_form');
328 328
 
329
-		$this->assertEquals( 1, count( $sections ) );
329
+		$this->assertEquals(1, count($sections));
330 330
 
331
-		$this->assertArrayHasKey( 'my_test_section', $sections );
331
+		$this->assertArrayHasKey('my_test_section', $sections);
332 332
 
333
-		$this->assertEquals( 'my_test_form', $sections['my_test_section']->get_form()->id );
333
+		$this->assertEquals('my_test_form', $sections['my_test_section']->get_form()->id);
334 334
 
335 335
 		// Get sections *from* form
336
-		$form = $wp_fields->get_form( $this->object_type, 'my_test_form', $this->object_name );
336
+		$form = $wp_fields->get_form($this->object_type, 'my_test_form', $this->object_name);
337 337
 
338
-		$sections = $form->get_children( 'section' );
338
+		$sections = $form->get_children('section');
339 339
 
340
-		$this->assertEquals( 1, count( $sections ) );
340
+		$this->assertEquals(1, count($sections));
341 341
 
342
-		$this->assertArrayHasKey( 'my_test_section', $sections );
342
+		$this->assertArrayHasKey('my_test_section', $sections);
343 343
 
344
-		$this->assertEquals( 'my_test_form', $sections['my_test_section']->get_form()->id );
344
+		$this->assertEquals('my_test_form', $sections['my_test_section']->get_form()->id);
345 345
 
346 346
 		// Get all sections for object type
347
-		$sections = $wp_fields->get_sections( $this->object_type, true );
347
+		$sections = $wp_fields->get_sections($this->object_type, true);
348 348
 
349
-		$this->assertEquals( 1, count( $sections ) );
349
+		$this->assertEquals(1, count($sections));
350 350
 
351
-		$section_ids = wp_list_pluck( $sections, 'id' );
351
+		$section_ids = wp_list_pluck($sections, 'id');
352 352
 
353
-		$this->assertContains( 'my_test_section', $section_ids );
353
+		$this->assertContains('my_test_section', $section_ids);
354 354
 
355 355
 		// Get all sections for all object types
356 356
 		$sections = $wp_fields->get_sections();
357 357
 
358 358
 		// Each array item is an object type with an array of object names
359
-		$this->assertEquals( 1, count( $sections ) );
359
+		$this->assertEquals(1, count($sections));
360 360
 
361
-		$this->assertArrayHasKey( $this->object_type, $sections );
361
+		$this->assertArrayHasKey($this->object_type, $sections);
362 362
 
363 363
 	}
364 364
 
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 		global $wp_fields;
374 374
 
375 375
 		// Add a form
376
-		$this->test_add_section( $this->object_type, $this->object_name );
376
+		$this->test_add_section($this->object_type, $this->object_name);
377 377
 
378 378
 		// Section exists for this object type / name
379
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section', $this->object_name );
379
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section', $this->object_name);
380 380
 
381
-		$this->assertNotEmpty( $section );
381
+		$this->assertNotEmpty($section);
382 382
 
383
-		$this->assertEquals( 'my_test_section', $section->id );
384
-		$this->assertEquals( 'my_test_form', $section->get_form()->id );
383
+		$this->assertEquals('my_test_section', $section->id);
384
+		$this->assertEquals('my_test_form', $section->get_form()->id);
385 385
 
386 386
 		// Section doesn't exist for this object type / name
387
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section', 'some_other_post_type' );
387
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section', 'some_other_post_type');
388 388
 
389
-		$this->assertEmpty( $section );
389
+		$this->assertEmpty($section);
390 390
 
391 391
 		// Section doesn't exist for this object type / name
392
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section2', $this->object_name );
392
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section2', $this->object_name);
393 393
 
394
-		$this->assertEmpty( $section );
394
+		$this->assertEmpty($section);
395 395
 
396 396
 	}
397 397
 
@@ -406,22 +406,22 @@  discard block
 block discarded – undo
406 406
 		global $wp_fields;
407 407
 
408 408
 		// Add a form
409
-		$this->test_add_section( $this->object_type, $this->object_name );
409
+		$this->test_add_section($this->object_type, $this->object_name);
410 410
 
411 411
 		// Section exists for this object type / name
412
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section', $this->object_name );
412
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section', $this->object_name);
413 413
 
414
-		$this->assertNotEmpty( $section );
414
+		$this->assertNotEmpty($section);
415 415
 
416
-		$this->assertEquals( 'my_test_section', $section->id );
416
+		$this->assertEquals('my_test_section', $section->id);
417 417
 
418 418
 		// Remove section
419
-		$wp_fields->remove_section( $this->object_type, 'my_test_section', $this->object_name );
419
+		$wp_fields->remove_section($this->object_type, 'my_test_section', $this->object_name);
420 420
 
421 421
 		// Section no longer exists for this object type / name
422
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section', $this->object_name );
422
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section', $this->object_name);
423 423
 
424
-		$this->assertEmpty( $section );
424
+		$this->assertEmpty($section);
425 425
 
426 426
 	}
427 427
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	 * @param string $object_type
432 432
 	 * @param string $object_name
433 433
 	 */
434
-	public function test_add_field( $object_type = 'post', $object_name = null ) {
434
+	public function test_add_field($object_type = 'post', $object_name = null) {
435 435
 
436 436
 		/**
437 437
 		 * @var $wp_fields WP_Fields_API
@@ -439,16 +439,16 @@  discard block
 block discarded – undo
439 439
 		global $wp_fields;
440 440
 
441 441
 		// Add a section for the control
442
-		$this->test_add_section( $object_type, $object_name );
442
+		$this->test_add_section($object_type, $object_name);
443 443
 
444
-		$wp_fields->add_field( $object_type, 'my_test_field', $object_name, array(
444
+		$wp_fields->add_field($object_type, 'my_test_field', $object_name, array(
445 445
 			'control' => array(
446 446
 				'id'      => 'my_test_field_control',
447 447
 				'label'   => 'My Test Field',
448 448
 				'type'    => 'text',
449 449
 				'section' => 'my_test_section',
450 450
 			),
451
-		) );
451
+		));
452 452
 
453 453
 	}
454 454
 
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 		global $wp_fields;
464 464
 
465 465
 		// Add a field
466
-		$this->test_add_field( $this->object_type, $this->object_name );
466
+		$this->test_add_field($this->object_type, $this->object_name);
467 467
 
468 468
 		// Get fields for object type / name
469
-		$fields = $wp_fields->get_fields( $this->object_type, $this->object_name );
469
+		$fields = $wp_fields->get_fields($this->object_type, $this->object_name);
470 470
 
471
-		$this->assertEquals( 1, count( $fields ) );
471
+		$this->assertEquals(1, count($fields));
472 472
 
473
-		$this->assertArrayHasKey( 'my_test_field', $fields );
473
+		$this->assertArrayHasKey('my_test_field', $fields);
474 474
 
475 475
 		// Get a field that doesn't exist
476
-		$fields = $wp_fields->get_fields( $this->object_type, 'some_other_post_type' );
476
+		$fields = $wp_fields->get_fields($this->object_type, 'some_other_post_type');
477 477
 
478
-		$this->assertEquals( 0, count( $fields ) );
478
+		$this->assertEquals(0, count($fields));
479 479
 
480 480
 	}
481 481
 
@@ -490,24 +490,24 @@  discard block
 block discarded – undo
490 490
 		global $wp_fields;
491 491
 
492 492
 		// Add a field
493
-		$this->test_add_field( $this->object_type, $this->object_name );
493
+		$this->test_add_field($this->object_type, $this->object_name);
494 494
 
495 495
 		// Field exists for this object type / name
496
-		$field = $wp_fields->get_field( $this->object_type, 'my_test_field', $this->object_name );
496
+		$field = $wp_fields->get_field($this->object_type, 'my_test_field', $this->object_name);
497 497
 
498
-		$this->assertNotEmpty( $field );
498
+		$this->assertNotEmpty($field);
499 499
 
500
-		$this->assertEquals( 'my_test_field', $field->id );
500
+		$this->assertEquals('my_test_field', $field->id);
501 501
 
502 502
 		// Field doesn't exist for this object type / name
503
-		$field = $wp_fields->get_field( $this->object_type, 'my_test_field', 'some_other_post_type' );
503
+		$field = $wp_fields->get_field($this->object_type, 'my_test_field', 'some_other_post_type');
504 504
 
505
-		$this->assertEmpty( $field );
505
+		$this->assertEmpty($field);
506 506
 
507 507
 		// Field doesn't exist for this object type / name
508
-		$field = $wp_fields->get_field( $this->object_type, 'my_test_field2', $this->object_name );
508
+		$field = $wp_fields->get_field($this->object_type, 'my_test_field2', $this->object_name);
509 509
 
510
-		$this->assertEmpty( $field );
510
+		$this->assertEmpty($field);
511 511
 
512 512
 	}
513 513
 
@@ -522,22 +522,22 @@  discard block
 block discarded – undo
522 522
 		global $wp_fields;
523 523
 
524 524
 		// Add a field
525
-		$this->test_add_field( $this->object_type, $this->object_name );
525
+		$this->test_add_field($this->object_type, $this->object_name);
526 526
 
527 527
 		// Field exists for this object type / name
528
-		$field = $wp_fields->get_field( $this->object_type, 'my_test_field', $this->object_name );
528
+		$field = $wp_fields->get_field($this->object_type, 'my_test_field', $this->object_name);
529 529
 
530
-		$this->assertNotEmpty( $field );
530
+		$this->assertNotEmpty($field);
531 531
 
532
-		$this->assertEquals( 'my_test_field', $field->id );
532
+		$this->assertEquals('my_test_field', $field->id);
533 533
 
534 534
 		// Remove field
535
-		$wp_fields->remove_field( $this->object_type, 'my_test_field', $this->object_name );
535
+		$wp_fields->remove_field($this->object_type, 'my_test_field', $this->object_name);
536 536
 
537 537
 		// Field no longer exists for this object type / name
538
-		$field = $wp_fields->get_field( $this->object_type, 'my_test_field', $this->object_name );
538
+		$field = $wp_fields->get_field($this->object_type, 'my_test_field', $this->object_name);
539 539
 
540
-		$this->assertEmpty( $field );
540
+		$this->assertEmpty($field);
541 541
 
542 542
 	}
543 543
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	 * @param string $object_type
548 548
 	 * @param string $object_name
549 549
 	 */
550
-	public function test_add_control( $object_type = 'post', $object_name = null ) {
550
+	public function test_add_control($object_type = 'post', $object_name = null) {
551 551
 
552 552
 		/**
553 553
 		 * @var $wp_fields WP_Fields_API
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 		global $wp_fields;
556 556
 
557 557
 		// Add a field for the control
558
-		$this->test_add_field( $object_type, $object_name );
558
+		$this->test_add_field($object_type, $object_name);
559 559
 
560
-		$wp_fields->add_control( $object_type, 'my_test_control', $object_name, array(
560
+		$wp_fields->add_control($object_type, 'my_test_control', $object_name, array(
561 561
 			'section' => 'my_test_section',
562 562
 			'field'   => 'my_test_field',
563 563
 			'label'   => 'My Test Control Field',
564 564
 			'type'    => 'text',
565
-		) );
565
+		));
566 566
 
567 567
 	}
568 568
 
@@ -577,45 +577,45 @@  discard block
 block discarded – undo
577 577
 		global $wp_fields;
578 578
 
579 579
 		// Add a control / field / section
580
-		$this->test_add_control( $this->object_type, $this->object_name );
580
+		$this->test_add_control($this->object_type, $this->object_name);
581 581
 
582 582
 		// Get controls for object type / name
583
-		$controls = $wp_fields->get_controls( $this->object_type, $this->object_name );
583
+		$controls = $wp_fields->get_controls($this->object_type, $this->object_name);
584 584
 
585 585
 		// There are two controls, the default one with the main field and this control
586
-		$this->assertEquals( 2, count( $controls ) );
586
+		$this->assertEquals(2, count($controls));
587 587
 
588
-		$this->assertArrayHasKey( 'my_test_control', $controls );
589
-		$this->assertArrayHasKey( 'my_test_field_control', $controls );
588
+		$this->assertArrayHasKey('my_test_control', $controls);
589
+		$this->assertArrayHasKey('my_test_field_control', $controls);
590 590
 
591
-		$this->assertEquals( 'my_test_section', $controls['my_test_control']->get_section()->id );
591
+		$this->assertEquals('my_test_section', $controls['my_test_control']->get_section()->id);
592 592
 
593 593
 		// Get a control that doesn't exist
594
-		$controls = $wp_fields->get_controls( $this->object_type, 'some_other_post_type' );
594
+		$controls = $wp_fields->get_controls($this->object_type, 'some_other_post_type');
595 595
 
596
-		$this->assertEquals( 0, count( $controls ) );
596
+		$this->assertEquals(0, count($controls));
597 597
 
598 598
 		// Get controls by section
599
-		$controls = $wp_fields->get_controls( $this->object_type, $this->object_name, 'my_test_section' );
599
+		$controls = $wp_fields->get_controls($this->object_type, $this->object_name, 'my_test_section');
600 600
 
601
-		$this->assertEquals( 2, count( $controls ) );
601
+		$this->assertEquals(2, count($controls));
602 602
 
603
-		$this->assertArrayHasKey( 'my_test_control', $controls );
604
-		$this->assertArrayHasKey( 'my_test_field_control', $controls );
603
+		$this->assertArrayHasKey('my_test_control', $controls);
604
+		$this->assertArrayHasKey('my_test_field_control', $controls);
605 605
 
606
-		$this->assertEquals( 'my_test_section', $controls['my_test_control']->get_section()->id );
606
+		$this->assertEquals('my_test_section', $controls['my_test_control']->get_section()->id);
607 607
 
608 608
 		// Get sections *from* form
609
-		$section = $wp_fields->get_section( $this->object_type, 'my_test_section', $this->object_name );
609
+		$section = $wp_fields->get_section($this->object_type, 'my_test_section', $this->object_name);
610 610
 
611
-		$controls = $section->get_children( 'control' );
611
+		$controls = $section->get_children('control');
612 612
 
613
-		$this->assertEquals( 2, count( $controls ) );
613
+		$this->assertEquals(2, count($controls));
614 614
 
615
-		$this->assertArrayHasKey( 'my_test_control', $controls );
616
-		$this->assertArrayHasKey( 'my_test_field_control', $controls );
615
+		$this->assertArrayHasKey('my_test_control', $controls);
616
+		$this->assertArrayHasKey('my_test_field_control', $controls);
617 617
 
618
-		$this->assertEquals( 'my_test_section', $controls['my_test_control']->get_section()->id );
618
+		$this->assertEquals('my_test_section', $controls['my_test_control']->get_section()->id);
619 619
 
620 620
 	}
621 621
 
@@ -630,37 +630,37 @@  discard block
 block discarded – undo
630 630
 		global $wp_fields;
631 631
 
632 632
 		// Add a control / field / section
633
-		$this->test_add_control( $this->object_type, $this->object_name );
633
+		$this->test_add_control($this->object_type, $this->object_name);
634 634
 
635 635
 		// Control exists for this object type / name
636
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_field_control', $this->object_name );
636
+		$control = $wp_fields->get_control($this->object_type, 'my_test_field_control', $this->object_name);
637 637
 
638
-		$this->assertNotEmpty( $control );
638
+		$this->assertNotEmpty($control);
639 639
 
640
-		$this->assertEquals( 'my_test_field_control', $control->id );
641
-		$this->assertNotEmpty( $control->get_field() );
642
-		$this->assertEquals( 'my_test_field', $control->get_field()->id );
643
-		$this->assertEquals( 'my_test_section', $control->get_section()->id );
640
+		$this->assertEquals('my_test_field_control', $control->id);
641
+		$this->assertNotEmpty($control->get_field());
642
+		$this->assertEquals('my_test_field', $control->get_field()->id);
643
+		$this->assertEquals('my_test_section', $control->get_section()->id);
644 644
 
645 645
 		// Control exists for this object type / name
646
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_control', $this->object_name );
646
+		$control = $wp_fields->get_control($this->object_type, 'my_test_control', $this->object_name);
647 647
 
648
-		$this->assertNotEmpty( $control );
648
+		$this->assertNotEmpty($control);
649 649
 
650
-		$this->assertEquals( 'my_test_control', $control->id );
651
-		$this->assertNotEmpty( $control->get_field() );
652
-		$this->assertEquals( 'my_test_field', $control->get_field()->id );
653
-		$this->assertEquals( 'my_test_section', $control->get_section()->id );
650
+		$this->assertEquals('my_test_control', $control->id);
651
+		$this->assertNotEmpty($control->get_field());
652
+		$this->assertEquals('my_test_field', $control->get_field()->id);
653
+		$this->assertEquals('my_test_section', $control->get_section()->id);
654 654
 
655 655
 		// Control doesn't exist for this object type / name
656
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_control', 'some_other_post_type' );
656
+		$control = $wp_fields->get_control($this->object_type, 'my_test_control', 'some_other_post_type');
657 657
 
658
-		$this->assertEmpty( $control );
658
+		$this->assertEmpty($control);
659 659
 
660 660
 		// Control doesn't exist for this object type / name
661
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_control2', $this->object_name );
661
+		$control = $wp_fields->get_control($this->object_type, 'my_test_control2', $this->object_name);
662 662
 
663
-		$this->assertEmpty( $control );
663
+		$this->assertEmpty($control);
664 664
 
665 665
 	}
666 666
 
@@ -675,32 +675,32 @@  discard block
 block discarded – undo
675 675
 		global $wp_fields;
676 676
 
677 677
 		// Add a control / field / section
678
-		$this->test_add_control( $this->object_type, $this->object_name );
678
+		$this->test_add_control($this->object_type, $this->object_name);
679 679
 
680 680
 		// Control exists for this object type / name
681
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_control', $this->object_name );
681
+		$control = $wp_fields->get_control($this->object_type, 'my_test_control', $this->object_name);
682 682
 
683
-		$this->assertNotEmpty( $control );
683
+		$this->assertNotEmpty($control);
684 684
 
685
-		$this->assertEquals( 'my_test_control', $control->id );
686
-		$this->assertEquals( 'my_test_field', $control->get_field()->id );
687
-		$this->assertEquals( 'my_test_section', $control->get_section()->id );
685
+		$this->assertEquals('my_test_control', $control->id);
686
+		$this->assertEquals('my_test_field', $control->get_field()->id);
687
+		$this->assertEquals('my_test_section', $control->get_section()->id);
688 688
 
689 689
 		// Remove control
690
-		$wp_fields->remove_control( $this->object_type, 'my_test_control', $this->object_name );
690
+		$wp_fields->remove_control($this->object_type, 'my_test_control', $this->object_name);
691 691
 
692 692
 		// Control no longer exists for this object type / name
693
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_control', $this->object_name );
693
+		$control = $wp_fields->get_control($this->object_type, 'my_test_control', $this->object_name);
694 694
 
695
-		$this->assertEmpty( $control );
695
+		$this->assertEmpty($control);
696 696
 
697 697
 		// Remove field's control
698
-		$wp_fields->remove_control( $this->object_type, 'my_test_field_control', $this->object_name );
698
+		$wp_fields->remove_control($this->object_type, 'my_test_field_control', $this->object_name);
699 699
 
700 700
 		// Control no longer exists for this object type / name
701
-		$control = $wp_fields->get_control( $this->object_type, 'my_test_field_control', $this->object_name );
701
+		$control = $wp_fields->get_control($this->object_type, 'my_test_field_control', $this->object_name);
702 702
 
703
-		$this->assertEmpty( $control );
703
+		$this->assertEmpty($control);
704 704
 
705 705
 	}
706 706
 
Please login to merge, or discard this patch.