Completed
Push — master ( 40f698...4ced32 )
by Scott Kingsley
02:19
created
tests/test-wp-fields-api.php 1 patch
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 		global $wp_fields;
18 18
 
19 19
 		// Reset WP Fields instance for testing purposes
20
-		$wp_fields->remove_form( true, true );
21
-		$wp_fields->remove_section( true, true );
22
-		$wp_fields->remove_field( true, true );
23
-		$wp_fields->remove_control( true, true );
20
+		$wp_fields->remove_form(true, true);
21
+		$wp_fields->remove_section(true, true);
22
+		$wp_fields->remove_field(true, true);
23
+		$wp_fields->remove_control(true, true);
24 24
 
25 25
 	}
26 26
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		 */
37 37
 		global $wp_fields;
38 38
 
39
-		$this->assertTrue( is_a( $wp_fields, 'WP_Fields_API' ) );
39
+		$this->assertTrue(is_a($wp_fields, 'WP_Fields_API'));
40 40
 
41 41
 	}
42 42
 
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 		global $wp_fields;
52 52
 
53 53
 		// Add a section / form
54
-		$this->test_add_section( 'post', 'my_custom_post_type' );
54
+		$this->test_add_section('post', 'my_custom_post_type');
55 55
 
56 56
 		// Get containers for object type / name
57
-		$containers = $wp_fields->get_containers( 'post', 'my_custom_post_type' );
57
+		$containers = $wp_fields->get_containers('post', 'my_custom_post_type');
58 58
 
59 59
 		// There are two containers, the form and the section
60
-		$this->assertEquals( 2, count( $containers ) );
60
+		$this->assertEquals(2, count($containers));
61 61
 
62
-		$this->assertArrayHasKey( 'my_test_form', $containers );
63
-		$this->assertArrayHasKey( 'my_test_section', $containers );
62
+		$this->assertArrayHasKey('my_test_form', $containers);
63
+		$this->assertArrayHasKey('my_test_section', $containers);
64 64
 
65 65
 		// Get a containers that doesn't exist
66
-		$containers = $wp_fields->get_containers( 'post' );
66
+		$containers = $wp_fields->get_containers('post');
67 67
 
68
-		$this->assertEquals( 0, count( $containers ) );
68
+		$this->assertEquals(0, count($containers));
69 69
 
70 70
 		// Get all containers for all object types
71 71
 		$containers = $wp_fields->get_containers();
72 72
 
73 73
 		// Each array item is an object type with an array of object names
74
-		$this->assertEquals( 1, count( $containers ) );
74
+		$this->assertEquals(1, count($containers));
75 75
 
76
-		$this->assertArrayHasKey( 'post', $containers );
76
+		$this->assertArrayHasKey('post', $containers);
77 77
 
78 78
 	}
79 79
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 		global $wp_fields;
89 89
 
90 90
 		// Add a section / form
91
-		$this->test_add_section( 'post', 'my_custom_post_type' );
91
+		$this->test_add_section('post', 'my_custom_post_type');
92 92
 
93 93
 		// Get containers for object type / name
94
-		$containers = $wp_fields->get_containers( 'post', true );
94
+		$containers = $wp_fields->get_containers('post', true);
95 95
 
96 96
 		// There are two containers, the form and the section
97
-		$this->assertEquals( 2, count( $containers ) );
97
+		$this->assertEquals(2, count($containers));
98 98
 
99
-		$container_ids = wp_list_pluck( $containers, 'id' );
99
+		$container_ids = wp_list_pluck($containers, 'id');
100 100
 
101
-		$this->assertContains( 'my_test_form', $container_ids );
102
-		$this->assertContains( 'my_test_section', $container_ids );
101
+		$this->assertContains('my_test_form', $container_ids);
102
+		$this->assertContains('my_test_section', $container_ids);
103 103
 
104 104
 	}
105 105
 
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 	 * @param string $object_type
110 110
 	 * @param string $object_name
111 111
 	 */
112
-	public function test_add_form( $object_type = 'post', $object_name = null ) {
112
+	public function test_add_form($object_type = 'post', $object_name = null) {
113 113
 
114 114
 		/**
115 115
 		 * @var $wp_fields WP_Fields_API
116 116
 		 */
117 117
 		global $wp_fields;
118 118
 
119
-		$wp_fields->add_form( $object_type, 'my_test_form', $object_name );
119
+		$wp_fields->add_form($object_type, 'my_test_form', $object_name);
120 120
 
121 121
 	}
122 122
 
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	 * @param string $object_type
127 127
 	 * @param string $object_name
128 128
 	 */
129
-	public function test_add_form_invalid( $object_type = 'post' ) {
129
+	public function test_add_form_invalid($object_type = 'post') {
130 130
 
131 131
 		/**
132 132
 		 * @var $wp_fields WP_Fields_API
133 133
 		 */
134 134
 		global $wp_fields;
135 135
 
136
-		$wp_fields->add_form( $object_type, null, null, array() );
136
+		$wp_fields->add_form($object_type, null, null, array());
137 137
 
138 138
 	}
139 139
 
@@ -148,37 +148,37 @@  discard block
 block discarded – undo
148 148
 		global $wp_fields;
149 149
 
150 150
 		// Add a form
151
-		$this->test_add_form( 'post', 'my_custom_post_type' );
151
+		$this->test_add_form('post', 'my_custom_post_type');
152 152
 
153 153
 		// Get forms for object type / name
154
-		$forms = $wp_fields->get_forms( 'post', 'my_custom_post_type' );
154
+		$forms = $wp_fields->get_forms('post', 'my_custom_post_type');
155 155
 
156
-		$this->assertEquals( 1, count( $forms ) );
156
+		$this->assertEquals(1, count($forms));
157 157
 
158
-		$this->assertArrayHasKey( 'my_test_form', $forms );
158
+		$this->assertArrayHasKey('my_test_form', $forms);
159 159
 
160 160
 		// Get a form that doesn't exist
161
-		$forms = $wp_fields->get_forms( 'post', 'some_other_post_type' );
161
+		$forms = $wp_fields->get_forms('post', 'some_other_post_type');
162 162
 
163
-		$this->assertEquals( 0, count( $forms ) );
163
+		$this->assertEquals(0, count($forms));
164 164
 
165 165
 		// Get all forms for object type
166
-		$forms = $wp_fields->get_forms( 'post', true );
166
+		$forms = $wp_fields->get_forms('post', true);
167 167
 
168
-		$this->assertEquals( 1, count( $forms ) );
168
+		$this->assertEquals(1, count($forms));
169 169
 
170
-		$form_ids = wp_list_pluck( $forms, 'id' );
170
+		$form_ids = wp_list_pluck($forms, 'id');
171 171
 
172
-		$this->assertContains( 'my_test_form', $form_ids );
172
+		$this->assertContains('my_test_form', $form_ids);
173 173
 
174 174
 		// Get all forms for all object types
175 175
 		$forms = $wp_fields->get_forms();
176 176
 
177 177
 		// Each array item is an object type with an array of object names
178
-		$this->assertEquals( 1, count( $forms ) );
178
+		$this->assertEquals(1, count($forms));
179 179
 
180 180
 		// Array keys are object types
181
-		$this->assertArrayHasKey( 'post', $forms );
181
+		$this->assertArrayHasKey('post', $forms);
182 182
 
183 183
 	}
184 184
 
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 		global $wp_fields;
194 194
 
195 195
 		// Add a form
196
-		$this->test_add_form( 'post' );
196
+		$this->test_add_form('post');
197 197
 
198 198
 		// Get forms for object type / name
199
-		$forms = $wp_fields->get_forms( 'post' );
199
+		$forms = $wp_fields->get_forms('post');
200 200
 
201
-		$this->assertEquals( 1, count( $forms ) );
201
+		$this->assertEquals(1, count($forms));
202 202
 
203
-		$this->assertArrayHasKey( 'my_test_form', $forms );
203
+		$this->assertArrayHasKey('my_test_form', $forms);
204 204
 
205 205
 	}
206 206
 
@@ -215,24 +215,24 @@  discard block
 block discarded – undo
215 215
 		global $wp_fields;
216 216
 
217 217
 		// Add a form
218
-		$this->test_add_form( 'post', 'my_custom_post_type' );
218
+		$this->test_add_form('post', 'my_custom_post_type');
219 219
 
220 220
 		// Form exists for this object type / name
221
-		$form = $wp_fields->get_form( 'post', 'my_test_form', 'my_custom_post_type' );
221
+		$form = $wp_fields->get_form('post', 'my_test_form', 'my_custom_post_type');
222 222
 
223
-		$this->assertNotEmpty( $form );
223
+		$this->assertNotEmpty($form);
224 224
 
225
-		$this->assertEquals( 'my_test_form', $form->id );
225
+		$this->assertEquals('my_test_form', $form->id);
226 226
 
227 227
 		// Form doesn't exist for this object type / name
228
-		$form = $wp_fields->get_form( 'post', 'my_test_form1' );
228
+		$form = $wp_fields->get_form('post', 'my_test_form1');
229 229
 
230
-		$this->assertEmpty( $form );
230
+		$this->assertEmpty($form);
231 231
 
232 232
 		// Form doesn't exist for this object type / name
233
-		$form = $wp_fields->get_form( 'post', 'my_test_form2', 'my_custom_post_type' );
233
+		$form = $wp_fields->get_form('post', 'my_test_form2', 'my_custom_post_type');
234 234
 
235
-		$this->assertEmpty( $form );
235
+		$this->assertEmpty($form);
236 236
 
237 237
 	}
238 238
 
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
 		global $wp_fields;
248 248
 
249 249
 		// Add a form
250
-		$this->test_add_form( 'post', 'my_custom_post_type' );
250
+		$this->test_add_form('post', 'my_custom_post_type');
251 251
 
252 252
 		// Form exists for this object type / name
253
-		$form = $wp_fields->get_form( 'post', 'my_test_form', 'my_custom_post_type' );
253
+		$form = $wp_fields->get_form('post', 'my_test_form', 'my_custom_post_type');
254 254
 
255
-		$this->assertNotEmpty( $form );
255
+		$this->assertNotEmpty($form);
256 256
 
257
-		$this->assertEquals( 'my_test_form', $form->id );
257
+		$this->assertEquals('my_test_form', $form->id);
258 258
 
259 259
 		// Remove form
260
-		$wp_fields->remove_form( 'post', 'my_test_form', 'my_custom_post_type' );
260
+		$wp_fields->remove_form('post', 'my_test_form', 'my_custom_post_type');
261 261
 
262 262
 		// Form no longer exists for this object type / name
263
-		$form = $wp_fields->get_form( 'post', 'my_test_form', 'my_custom_post_type' );
263
+		$form = $wp_fields->get_form('post', 'my_test_form', 'my_custom_post_type');
264 264
 
265
-		$this->assertEmpty( $form );
265
+		$this->assertEmpty($form);
266 266
 
267 267
 	}
268 268
 
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 		global $wp_fields;
278 278
 
279 279
 		// Add a form
280
-		$this->test_add_form( 'post', 'my_custom_post_type' );
280
+		$this->test_add_form('post', 'my_custom_post_type');
281 281
 
282 282
 		// Remove form
283
-		$wp_fields->remove_form( 'post', null, true );
283
+		$wp_fields->remove_form('post', null, true);
284 284
 
285 285
 		// Form no longer exists for this object type / name
286
-		$form = $wp_fields->get_form( 'post', 'my_test_form', 'my_custom_post_type' );
286
+		$form = $wp_fields->get_form('post', 'my_test_form', 'my_custom_post_type');
287 287
 
288
-		$this->assertEmpty( $form );
288
+		$this->assertEmpty($form);
289 289
 
290 290
 	}
291 291
 
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 		global $wp_fields;
301 301
 
302 302
 		// Add a form
303
-		$this->test_add_form( 'post' );
303
+		$this->test_add_form('post');
304 304
 
305 305
 		// Remove form
306
-		$wp_fields->remove_form( 'post', 'my_test_form' );
306
+		$wp_fields->remove_form('post', 'my_test_form');
307 307
 
308 308
 		// Form no longer exists for this object type / name
309
-		$form = $wp_fields->get_form( 'post', 'my_test_form' );
309
+		$form = $wp_fields->get_form('post', 'my_test_form');
310 310
 
311
-		$this->assertEmpty( $form );
311
+		$this->assertEmpty($form);
312 312
 
313 313
 	}
314 314
 
@@ -323,15 +323,15 @@  discard block
 block discarded – undo
323 323
 		global $wp_fields;
324 324
 
325 325
 		// Add a form
326
-		$this->test_add_form( 'post', 'my_custom_post_type' );
326
+		$this->test_add_form('post', 'my_custom_post_type');
327 327
 
328 328
 		// Remove form
329
-		$wp_fields->remove_form( 'post', true, 'my_custom_post_type' );
329
+		$wp_fields->remove_form('post', true, 'my_custom_post_type');
330 330
 
331 331
 		// Form no longer exists for this object type / name
332
-		$form = $wp_fields->get_form( 'post', 'my_test_form', 'my_custom_post_type' );
332
+		$form = $wp_fields->get_form('post', 'my_test_form', 'my_custom_post_type');
333 333
 
334
-		$this->assertEmpty( $form );
334
+		$this->assertEmpty($form);
335 335
 
336 336
 	}
337 337
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	 * @param string $object_type
342 342
 	 * @param string $object_name
343 343
 	 */
344
-	public function test_add_section( $object_type = 'post', $object_name = null ) {
344
+	public function test_add_section($object_type = 'post', $object_name = null) {
345 345
 
346 346
 		/**
347 347
 		 * @var $wp_fields WP_Fields_API
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 		global $wp_fields;
350 350
 
351 351
 		// Add a form
352
-		$this->test_add_form( $object_type, $object_name );
352
+		$this->test_add_form($object_type, $object_name);
353 353
 
354
-		$wp_fields->add_section( $object_type, 'my_test_section', $object_name, array(
354
+		$wp_fields->add_section($object_type, 'my_test_section', $object_name, array(
355 355
 			'form' => 'my_test_form',
356
-		) );
356
+		));
357 357
 
358 358
 	}
359 359
 
@@ -368,43 +368,43 @@  discard block
 block discarded – undo
368 368
 		global $wp_fields;
369 369
 
370 370
 		// Add a form
371
-		$this->test_add_section( 'post', 'my_custom_post_type' );
371
+		$this->test_add_section('post', 'my_custom_post_type');
372 372
 
373 373
 		// Get sections for object type / name
374
-		$sections = $wp_fields->get_sections( 'post', 'my_custom_post_type' );
374
+		$sections = $wp_fields->get_sections('post', 'my_custom_post_type');
375 375
 
376
-		$this->assertEquals( 1, count( $sections ) );
376
+		$this->assertEquals(1, count($sections));
377 377
 
378
-		$this->assertArrayHasKey( 'my_test_section', $sections );
378
+		$this->assertArrayHasKey('my_test_section', $sections);
379 379
 
380 380
 		// Get a section that doesn't exist
381
-		$sections = $wp_fields->get_sections( 'post', 'some_other_post_type' );
381
+		$sections = $wp_fields->get_sections('post', 'some_other_post_type');
382 382
 
383
-		$this->assertEquals( 0, count( $sections ) );
383
+		$this->assertEquals(0, count($sections));
384 384
 
385 385
 		// Get sections by form
386
-		$sections = $wp_fields->get_sections( 'post', 'my_custom_post_type', 'my_test_form' );
386
+		$sections = $wp_fields->get_sections('post', 'my_custom_post_type', 'my_test_form');
387 387
 
388
-		$this->assertEquals( 1, count( $sections ) );
388
+		$this->assertEquals(1, count($sections));
389 389
 
390
-		$this->assertArrayHasKey( 'my_test_section', $sections );
390
+		$this->assertArrayHasKey('my_test_section', $sections);
391 391
 
392 392
 		// Get all sections for object type
393
-		$sections = $wp_fields->get_sections( 'post', true );
393
+		$sections = $wp_fields->get_sections('post', true);
394 394
 
395
-		$this->assertEquals( 1, count( $sections ) );
395
+		$this->assertEquals(1, count($sections));
396 396
 
397
-		$section_ids = wp_list_pluck( $sections, 'id' );
397
+		$section_ids = wp_list_pluck($sections, 'id');
398 398
 
399
-		$this->assertContains( 'my_test_section', $section_ids );
399
+		$this->assertContains('my_test_section', $section_ids);
400 400
 
401 401
 		// Get all sections for all object types
402 402
 		$sections = $wp_fields->get_sections();
403 403
 
404 404
 		// Each array item is an object type with an array of object names
405
-		$this->assertEquals( 1, count( $sections ) );
405
+		$this->assertEquals(1, count($sections));
406 406
 
407
-		$this->assertArrayHasKey( 'post', $sections );
407
+		$this->assertArrayHasKey('post', $sections);
408 408
 
409 409
 	}
410 410
 
@@ -419,24 +419,24 @@  discard block
 block discarded – undo
419 419
 		global $wp_fields;
420 420
 
421 421
 		// Add a form
422
-		$this->test_add_section( 'post', 'my_custom_post_type' );
422
+		$this->test_add_section('post', 'my_custom_post_type');
423 423
 
424 424
 		// Section exists for this object type / name
425
-		$section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' );
425
+		$section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type');
426 426
 
427
-		$this->assertNotEmpty( $section );
427
+		$this->assertNotEmpty($section);
428 428
 
429
-		$this->assertEquals( 'my_test_section', $section->id );
429
+		$this->assertEquals('my_test_section', $section->id);
430 430
 
431 431
 		// Section doesn't exist for this object type / name
432
-		$section = $wp_fields->get_section( 'post', 'my_test_section', 'some_other_post_type' );
432
+		$section = $wp_fields->get_section('post', 'my_test_section', 'some_other_post_type');
433 433
 
434
-		$this->assertEmpty( $section );
434
+		$this->assertEmpty($section);
435 435
 
436 436
 		// Section doesn't exist for this object type / name
437
-		$section = $wp_fields->get_section( 'post', 'my_test_section2', 'my_custom_post_type' );
437
+		$section = $wp_fields->get_section('post', 'my_test_section2', 'my_custom_post_type');
438 438
 
439
-		$this->assertEmpty( $section );
439
+		$this->assertEmpty($section);
440 440
 
441 441
 	}
442 442
 
@@ -451,22 +451,22 @@  discard block
 block discarded – undo
451 451
 		global $wp_fields;
452 452
 
453 453
 		// Add a form
454
-		$this->test_add_section( 'post', 'my_custom_post_type' );
454
+		$this->test_add_section('post', 'my_custom_post_type');
455 455
 
456 456
 		// Section exists for this object type / name
457
-		$section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' );
457
+		$section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type');
458 458
 
459
-		$this->assertNotEmpty( $section );
459
+		$this->assertNotEmpty($section);
460 460
 
461
-		$this->assertEquals( 'my_test_section', $section->id );
461
+		$this->assertEquals('my_test_section', $section->id);
462 462
 
463 463
 		// Remove section
464
-		$wp_fields->remove_section( 'post', 'my_test_section', 'my_custom_post_type' );
464
+		$wp_fields->remove_section('post', 'my_test_section', 'my_custom_post_type');
465 465
 
466 466
 		// Section no longer exists for this object type / name
467
-		$section = $wp_fields->get_section( 'post', 'my_test_section', 'my_custom_post_type' );
467
+		$section = $wp_fields->get_section('post', 'my_test_section', 'my_custom_post_type');
468 468
 
469
-		$this->assertEmpty( $section );
469
+		$this->assertEmpty($section);
470 470
 
471 471
 	}
472 472
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 * @param string $object_type
477 477
 	 * @param string $object_name
478 478
 	 */
479
-	public function test_add_field( $object_type = 'post', $object_name = null ) {
479
+	public function test_add_field($object_type = 'post', $object_name = null) {
480 480
 
481 481
 		/**
482 482
 		 * @var $wp_fields WP_Fields_API
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
 		global $wp_fields;
485 485
 
486 486
 		// Add a section for the control
487
-		$this->test_add_section( $object_type, $object_name );
487
+		$this->test_add_section($object_type, $object_name);
488 488
 
489
-		$wp_fields->add_field( $object_type, 'my_test_field', $object_name, array(
489
+		$wp_fields->add_field($object_type, 'my_test_field', $object_name, array(
490 490
 			'control' => array(
491 491
 				'id' => 'my_test_field_control',
492 492
 				'label' => 'My Test Field',
493 493
 				'type' => 'text',
494 494
 				'section' => 'my_test_section',
495 495
 			),
496
-		) );
496
+		));
497 497
 
498 498
 	}
499 499
 
@@ -508,26 +508,26 @@  discard block
 block discarded – undo
508 508
 		global $wp_fields;
509 509
 
510 510
 		// Add a field
511
-		$this->test_add_field( 'post', 'my_custom_post_type' );
511
+		$this->test_add_field('post', 'my_custom_post_type');
512 512
 
513 513
 		// Get fields for object type / name
514
-		$fields = $wp_fields->get_fields( 'post', 'my_custom_post_type' );
514
+		$fields = $wp_fields->get_fields('post', 'my_custom_post_type');
515 515
 
516
-		$this->assertEquals( 1, count( $fields ) );
516
+		$this->assertEquals(1, count($fields));
517 517
 
518
-		$this->assertArrayHasKey( 'my_test_field', $fields );
518
+		$this->assertArrayHasKey('my_test_field', $fields);
519 519
 
520 520
 		// Get a field that doesn't exist
521
-		$fields = $wp_fields->get_fields( 'post', 'some_other_post_type' );
521
+		$fields = $wp_fields->get_fields('post', 'some_other_post_type');
522 522
 
523
-		$this->assertEquals( 0, count( $fields ) );
523
+		$this->assertEquals(0, count($fields));
524 524
 
525 525
 		// Get fields by section
526
-		$fields = $wp_fields->get_fields( 'post', 'my_custom_post_type', 'my_test_section' );
526
+		$fields = $wp_fields->get_fields('post', 'my_custom_post_type', 'my_test_section');
527 527
 
528
-		$this->assertEquals( 1, count( $fields ) );
528
+		$this->assertEquals(1, count($fields));
529 529
 
530
-		$this->assertArrayHasKey( 'my_test_field', $fields );
530
+		$this->assertArrayHasKey('my_test_field', $fields);
531 531
 
532 532
 	}
533 533
 
@@ -542,24 +542,24 @@  discard block
 block discarded – undo
542 542
 		global $wp_fields;
543 543
 
544 544
 		// Add a field
545
-		$this->test_add_field( 'post', 'my_custom_post_type' );
545
+		$this->test_add_field('post', 'my_custom_post_type');
546 546
 
547 547
 		// Field exists for this object type / name
548
-		$field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' );
548
+		$field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type');
549 549
 
550
-		$this->assertNotEmpty( $field );
550
+		$this->assertNotEmpty($field);
551 551
 
552
-		$this->assertEquals( 'my_test_field', $field->id );
552
+		$this->assertEquals('my_test_field', $field->id);
553 553
 
554 554
 		// Field doesn't exist for this object type / name
555
-		$field = $wp_fields->get_field( 'post', 'my_test_field', 'some_other_post_type' );
555
+		$field = $wp_fields->get_field('post', 'my_test_field', 'some_other_post_type');
556 556
 
557
-		$this->assertEmpty( $field );
557
+		$this->assertEmpty($field);
558 558
 
559 559
 		// Field doesn't exist for this object type / name
560
-		$field = $wp_fields->get_field( 'post', 'my_test_field2', 'my_custom_post_type' );
560
+		$field = $wp_fields->get_field('post', 'my_test_field2', 'my_custom_post_type');
561 561
 
562
-		$this->assertEmpty( $field );
562
+		$this->assertEmpty($field);
563 563
 
564 564
 	}
565 565
 
@@ -574,22 +574,22 @@  discard block
 block discarded – undo
574 574
 		global $wp_fields;
575 575
 
576 576
 		// Add a field
577
-		$this->test_add_field( 'post', 'my_custom_post_type' );
577
+		$this->test_add_field('post', 'my_custom_post_type');
578 578
 
579 579
 		// Field exists for this object type / name
580
-		$field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' );
580
+		$field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type');
581 581
 
582
-		$this->assertNotEmpty( $field );
582
+		$this->assertNotEmpty($field);
583 583
 
584
-		$this->assertEquals( 'my_test_field', $field->id );
584
+		$this->assertEquals('my_test_field', $field->id);
585 585
 
586 586
 		// Remove field
587
-		$wp_fields->remove_field( 'post', 'my_test_field', 'my_custom_post_type' );
587
+		$wp_fields->remove_field('post', 'my_test_field', 'my_custom_post_type');
588 588
 
589 589
 		// Field no longer exists for this object type / name
590
-		$field = $wp_fields->get_field( 'post', 'my_test_field', 'my_custom_post_type' );
590
+		$field = $wp_fields->get_field('post', 'my_test_field', 'my_custom_post_type');
591 591
 
592
-		$this->assertEmpty( $field );
592
+		$this->assertEmpty($field);
593 593
 
594 594
 	}
595 595
 
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @param string $object_type
600 600
 	 * @param string $object_name
601 601
 	 */
602
-	public function test_add_control( $object_type = 'post', $object_name = null ) {
602
+	public function test_add_control($object_type = 'post', $object_name = null) {
603 603
 
604 604
 		/**
605 605
 		 * @var $wp_fields WP_Fields_API
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 		global $wp_fields;
608 608
 
609 609
 		// Add a field for the control
610
-		$this->test_add_field( $object_type, $object_name );
610
+		$this->test_add_field($object_type, $object_name);
611 611
 
612
-		$wp_fields->add_control( $object_type, 'my_test_control', $object_name, array(
612
+		$wp_fields->add_control($object_type, 'my_test_control', $object_name, array(
613 613
 			'section' => 'my_test_section',
614 614
 			'fields' => 'my_test_field',
615 615
 			'label' => 'My Test Control Field',
616 616
 			'type' => 'text',
617
-		) );
617
+		));
618 618
 
619 619
 	}
620 620
 
@@ -629,33 +629,33 @@  discard block
 block discarded – undo
629 629
 		global $wp_fields;
630 630
 
631 631
 		// Add a control / field / section
632
-		$this->test_add_control( 'post', 'my_custom_post_type' );
632
+		$this->test_add_control('post', 'my_custom_post_type');
633 633
 
634 634
 		// Get controls for object type / name
635
-		$controls = $wp_fields->get_controls( 'post', 'my_custom_post_type' );
635
+		$controls = $wp_fields->get_controls('post', 'my_custom_post_type');
636 636
 
637 637
 		// There are two controls, the default one with the main field and this control
638
-		$this->assertEquals( 2, count( $controls ) );
638
+		$this->assertEquals(2, count($controls));
639 639
 
640
-		$this->assertArrayHasKey( 'my_test_control', $controls );
641
-		$this->assertArrayHasKey( 'my_test_field_control', $controls );
640
+		$this->assertArrayHasKey('my_test_control', $controls);
641
+		$this->assertArrayHasKey('my_test_field_control', $controls);
642 642
 
643
-		$this->assertEquals( 'my_test_section', $controls['my_test_control']->section );
643
+		$this->assertEquals('my_test_section', $controls['my_test_control']->section);
644 644
 
645 645
 		// Get a control that doesn't exist
646
-		$controls = $wp_fields->get_controls( 'post', 'some_other_post_type' );
646
+		$controls = $wp_fields->get_controls('post', 'some_other_post_type');
647 647
 
648
-		$this->assertEquals( 0, count( $controls ) );
648
+		$this->assertEquals(0, count($controls));
649 649
 
650 650
 		// Get controls by section
651
-		$controls = $wp_fields->get_controls( 'post', 'my_custom_post_type', 'my_test_section' );
651
+		$controls = $wp_fields->get_controls('post', 'my_custom_post_type', 'my_test_section');
652 652
 
653
-		$this->assertEquals( 2, count( $controls ) );
653
+		$this->assertEquals(2, count($controls));
654 654
 
655
-		$this->assertArrayHasKey( 'my_test_control', $controls );
656
-		$this->assertArrayHasKey( 'my_test_field_control', $controls );
655
+		$this->assertArrayHasKey('my_test_control', $controls);
656
+		$this->assertArrayHasKey('my_test_field_control', $controls);
657 657
 
658
-		$this->assertEquals( 'my_test_section', $controls['my_test_control']->section );
658
+		$this->assertEquals('my_test_section', $controls['my_test_control']->section);
659 659
 
660 660
 	}
661 661
 
@@ -670,37 +670,37 @@  discard block
 block discarded – undo
670 670
 		global $wp_fields;
671 671
 
672 672
 		// Add a control / field / section
673
-		$this->test_add_control( 'post', 'my_custom_post_type' );
673
+		$this->test_add_control('post', 'my_custom_post_type');
674 674
 
675 675
 		// Control exists for this object type / name
676
-		$control = $wp_fields->get_control( 'post', 'my_test_field_control', 'my_custom_post_type' );
676
+		$control = $wp_fields->get_control('post', 'my_test_field_control', 'my_custom_post_type');
677 677
 
678
-		$this->assertNotEmpty( $control );
678
+		$this->assertNotEmpty($control);
679 679
 
680
-		$this->assertEquals( 'my_test_field_control', $control->id );
681
-		$this->assertNotEmpty( $control->field );
682
-		$this->assertEquals( 'my_test_field', $control->field->id );
683
-		$this->assertEquals( 'my_test_section', $control->section );
680
+		$this->assertEquals('my_test_field_control', $control->id);
681
+		$this->assertNotEmpty($control->field);
682
+		$this->assertEquals('my_test_field', $control->field->id);
683
+		$this->assertEquals('my_test_section', $control->section);
684 684
 
685 685
 		// Control exists for this object type / name
686
-		$control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' );
686
+		$control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type');
687 687
 
688
-		$this->assertNotEmpty( $control );
688
+		$this->assertNotEmpty($control);
689 689
 
690
-		$this->assertEquals( 'my_test_control', $control->id );
691
-		$this->assertNotEmpty( $control->field );
692
-		$this->assertEquals( 'my_test_field', $control->field->id );
693
-		$this->assertEquals( 'my_test_section', $control->section );
690
+		$this->assertEquals('my_test_control', $control->id);
691
+		$this->assertNotEmpty($control->field);
692
+		$this->assertEquals('my_test_field', $control->field->id);
693
+		$this->assertEquals('my_test_section', $control->section);
694 694
 
695 695
 		// Control doesn't exist for this object type / name
696
-		$control = $wp_fields->get_control( 'post', 'my_test_control', 'some_other_post_type' );
696
+		$control = $wp_fields->get_control('post', 'my_test_control', 'some_other_post_type');
697 697
 
698
-		$this->assertEmpty( $control );
698
+		$this->assertEmpty($control);
699 699
 
700 700
 		// Control doesn't exist for this object type / name
701
-		$control = $wp_fields->get_control( 'post', 'my_test_control2', 'my_custom_post_type' );
701
+		$control = $wp_fields->get_control('post', 'my_test_control2', 'my_custom_post_type');
702 702
 
703
-		$this->assertEmpty( $control );
703
+		$this->assertEmpty($control);
704 704
 
705 705
 	}
706 706
 
@@ -715,32 +715,32 @@  discard block
 block discarded – undo
715 715
 		global $wp_fields;
716 716
 
717 717
 		// Add a control / field / section
718
-		$this->test_add_control( 'post', 'my_custom_post_type' );
718
+		$this->test_add_control('post', 'my_custom_post_type');
719 719
 
720 720
 		// Control exists for this object type / name
721
-		$control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' );
721
+		$control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type');
722 722
 
723
-		$this->assertNotEmpty( $control );
723
+		$this->assertNotEmpty($control);
724 724
 
725
-		$this->assertEquals( 'my_test_control', $control->id );
726
-		$this->assertEquals( 'my_test_field', $control->field->id );
727
-		$this->assertEquals( 'my_test_section', $control->section );
725
+		$this->assertEquals('my_test_control', $control->id);
726
+		$this->assertEquals('my_test_field', $control->field->id);
727
+		$this->assertEquals('my_test_section', $control->section);
728 728
 
729 729
 		// Remove control
730
-		$wp_fields->remove_control( 'post', 'my_test_control', 'my_custom_post_type' );
730
+		$wp_fields->remove_control('post', 'my_test_control', 'my_custom_post_type');
731 731
 
732 732
 		// Control no longer exists for this object type / name
733
-		$control = $wp_fields->get_control( 'post', 'my_test_control', 'my_custom_post_type' );
733
+		$control = $wp_fields->get_control('post', 'my_test_control', 'my_custom_post_type');
734 734
 
735
-		$this->assertEmpty( $control );
735
+		$this->assertEmpty($control);
736 736
 
737 737
 		// Remove field's control
738
-		$wp_fields->remove_control( 'post', 'my_test_field_control', 'my_custom_post_type' );
738
+		$wp_fields->remove_control('post', 'my_test_field_control', 'my_custom_post_type');
739 739
 
740 740
 		// Control no longer exists for this object type / name
741
-		$control = $wp_fields->get_control( 'post', 'my_test_field_control', 'my_custom_post_type' );
741
+		$control = $wp_fields->get_control('post', 'my_test_field_control', 'my_custom_post_type');
742 742
 
743
-		$this->assertEmpty( $control );
743
+		$this->assertEmpty($control);
744 744
 
745 745
 	}
746 746
 
Please login to merge, or discard this patch.
wordpress-fields-api.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -22,32 +22,32 @@  discard block
 block discarded – undo
22 22
 /**
23 23
  * The absolute server path to the fields API directory.
24 24
  */
25
-define( 'WP_FIELDS_API_DIR', plugin_dir_path( __FILE__ ) );
25
+define('WP_FIELDS_API_DIR', plugin_dir_path(__FILE__));
26 26
 
27 27
 /**
28 28
  * On `plugins_loaded`, create an instance of the Fields API manager class.
29 29
  */
30 30
 function _wp_fields_api_include() {
31 31
 
32
-	require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/fields-api/class-wp-fields-api.php' );
32
+	require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/fields-api/class-wp-fields-api.php');
33 33
 
34 34
 	// Init Fields API class
35 35
 	$GLOBALS['wp_fields'] = WP_Fields_API::get_instance();
36 36
 
37 37
 }
38 38
 
39
-add_action( 'plugins_loaded', '_wp_fields_api_include', 8 );
39
+add_action('plugins_loaded', '_wp_fields_api_include', 8);
40 40
 
41 41
 /**
42 42
  * Implement Fields API Customizer instead of WP Core Customizer.
43 43
  */
44 44
 function _wp_fields_api_customize_include() {
45 45
 
46
-	if ( ! ( ( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] ) || ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) ) ) ) {
46
+	if ( ! ((isset($_REQUEST['wp_customize']) && 'on' == $_REQUEST['wp_customize']) || (is_admin() && 'customize.php' == basename($_SERVER['PHP_SELF'])))) {
47 47
 		return;
48 48
 	}
49 49
 
50
-	require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
50
+	require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
51 51
 
52 52
 	// Init Customize class
53 53
 	$GLOBALS['wp_customize'] = new WP_Customize_Manager;
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function _wp_fields_api_implementations() {
64 64
 
65
-	$implementation_dir = WP_FIELDS_API_DIR . 'implementation/wp-includes/fields-api/forms/';
65
+	$implementation_dir = WP_FIELDS_API_DIR.'implementation/wp-includes/fields-api/forms/';
66 66
 
67 67
 	// User
68
-	require_once( $implementation_dir . 'class-wp-fields-api-form-user-edit.php' );
68
+	require_once($implementation_dir.'class-wp-fields-api-form-user-edit.php');
69 69
 
70
-	WP_Fields_API_Form_User_Edit::register( 'user', 'user-edit' );
70
+	WP_Fields_API_Form_User_Edit::register('user', 'user-edit');
71 71
 
72 72
 	// Term
73
-	require_once( $implementation_dir . 'class-wp-fields-api-form-term.php' );
74
-	require_once( $implementation_dir . 'class-wp-fields-api-form-term-add.php' );
73
+	require_once($implementation_dir.'class-wp-fields-api-form-term.php');
74
+	require_once($implementation_dir.'class-wp-fields-api-form-term-add.php');
75 75
 
76
-	WP_Fields_API_Form_Term::register( 'term', 'term-edit' );
77
-	WP_Fields_API_Form_Term_Add::register( 'term', 'term-add' );
76
+	WP_Fields_API_Form_Term::register('term', 'term-edit');
77
+	WP_Fields_API_Form_Term_Add::register('term', 'term-add');
78 78
 
79 79
 }
80
-add_action( 'fields_register', '_wp_fields_api_implementations', 5 );
80
+add_action('fields_register', '_wp_fields_api_implementations', 5);
81 81
 
82 82
 /**
83 83
  * Implement Fields API User edit to override WP Core.
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
 
87 87
 	static $overridden;
88 88
 
89
-	if ( empty( $overridden ) ) {
89
+	if (empty($overridden)) {
90 90
 		$overridden = true;
91 91
 
92 92
 		// Load our overrides
93 93
 		//require_once( WP_FIELDS_API_DIR . 'implementation/wp-admin/includes/user.php' );
94
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-admin/user-edit.php' );
94
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-admin/user-edit.php');
95 95
 
96 96
 		// Bail on original core file, don't run the rest
97 97
 		exit;
98 98
 	}
99 99
 
100 100
 }
101
-add_action( 'load-user-edit.php', '_wp_fields_api_user_edit_include' );
102
-add_action( 'load-profile.php', '_wp_fields_api_user_edit_include' );
101
+add_action('load-user-edit.php', '_wp_fields_api_user_edit_include');
102
+add_action('load-profile.php', '_wp_fields_api_user_edit_include');
103 103
 
104 104
 
105 105
 /**
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 
110 110
 	static $overridden;
111 111
 
112
-	if ( empty( $overridden ) ) {
112
+	if (empty($overridden)) {
113 113
 		$overridden = true;
114 114
 
115 115
 		// Load our overrides
116
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-admin/edit-tags.php' );
116
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-admin/edit-tags.php');
117 117
 
118 118
 		// Bail on original core file, don't run the rest
119 119
 		exit;
120 120
 	}
121 121
 
122 122
 }
123
-add_action( 'load-edit-tags.php', '_wp_fields_api_term_include' );
124 123
\ No newline at end of file
124
+add_action('load-edit-tags.php', '_wp_fields_api_term_include');
125 125
\ No newline at end of file
Please login to merge, or discard this patch.