Completed
Push — master ( e23be5...9cf38f )
by Scott Kingsley
02:09
created
tests/test-wp-fields-api.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,6 @@
 block discarded – undo
124 124
 	 * Test WP_Fields_API::add_screen()
125 125
 	 *
126 126
 	 * @param string $object_type
127
-	 * @param string $object_name
128 127
 	 */
129 128
 	public function test_add_screen_invalid( $object_type = 'post' ) {
130 129
 
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class WP_Test_Fields_API_Testcase
4
- *
5
- * @uses PHPUnit_Framework_TestCase
6
- */
3
+	 * Class WP_Test_Fields_API_Testcase
4
+	 *
5
+	 * @uses PHPUnit_Framework_TestCase
6
+	 */
7 7
 class WP_Test_Fields_API_Testcase extends WP_UnitTestCase {
8 8
 
9 9
 	public function tearDown() {
Please login to merge, or discard this 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.
tests/core/nav-menu-item-setting.php 2 patches
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	function setUp() {
22 22
 		parent::setUp();
23
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
23
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
24 24
 		//require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
25
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
25
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
26 26
 
27 27
 		global $wp_customize;
28 28
 		$this->wp_customize = new WP_Customize_Manager();
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param object $menu_item Menu item.
45 45
 	 * @return object
46 46
 	 */
47
-	function filter_type_label( $menu_item ) {
48
-		if ( 'custom_type' === $menu_item->type ) {
47
+	function filter_type_label($menu_item) {
48
+		if ('custom_type' === $menu_item->type) {
49 49
 			$menu_item->type_label = 'Custom Label';
50 50
 		}
51 51
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * Test constants and statics.
57 57
 	 */
58 58
 	function test_constants() {
59
-		do_action( 'customize_register', $this->wp_customize );
60
-		$this->assertTrue( post_type_exists( WP_Customize_Nav_Menu_Item_Setting::POST_TYPE ) );
59
+		do_action('customize_register', $this->wp_customize);
60
+		$this->assertTrue(post_type_exists(WP_Customize_Nav_Menu_Item_Setting::POST_TYPE));
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 * @see WP_Customize_Nav_Menu_Item_Setting::__construct()
67 67
 	 */
68 68
 	function test_construct() {
69
-		do_action( 'customize_register', $this->wp_customize );
69
+		do_action('customize_register', $this->wp_customize);
70 70
 
71
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' );
72
-		$this->assertEquals( 'nav_menu_item', $setting->type );
73
-		$this->assertEquals( 'postMessage', $setting->transport );
74
-		$this->assertEquals( 123, $setting->post_id );
75
-		$this->assertNull( $setting->previous_post_id );
76
-		$this->assertNull( $setting->update_status );
77
-		$this->assertNull( $setting->update_error );
78
-		$this->assertInternalType( 'array', $setting->default );
71
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[123]');
72
+		$this->assertEquals('nav_menu_item', $setting->type);
73
+		$this->assertEquals('postMessage', $setting->transport);
74
+		$this->assertEquals(123, $setting->post_id);
75
+		$this->assertNull($setting->previous_post_id);
76
+		$this->assertNull($setting->update_status);
77
+		$this->assertNull($setting->update_error);
78
+		$this->assertInternalType('array', $setting->default);
79 79
 
80 80
 		$default = array(
81 81
 			'object_id' => 0,
@@ -94,34 +94,34 @@  discard block
 block discarded – undo
94 94
 			'original_title' => '',
95 95
 			'nav_menu_term_id' => 0,
96 96
 		);
97
-		$this->assertEquals( $default, $setting->default );
97
+		$this->assertEquals($default, $setting->default);
98 98
 
99 99
 		$exception = null;
100 100
 		try {
101
-			$bad_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'foo_bar_baz' );
102
-			unset( $bad_setting );
103
-		} catch ( Exception $e ) {
101
+			$bad_setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'foo_bar_baz');
102
+			unset($bad_setting);
103
+		} catch (Exception $e) {
104 104
 			$exception = $e;
105 105
 		}
106
-		$this->assertInstanceOf( 'Exception', $exception );
106
+		$this->assertInstanceOf('Exception', $exception);
107 107
 	}
108 108
 
109 109
 	/**
110 110
 	 * Test empty constructor.
111 111
 	 */
112 112
 	function test_construct_empty_menus() {
113
-		do_action( 'customize_register', $this->wp_customize );
113
+		do_action('customize_register', $this->wp_customize);
114 114
 		$_wp_customize = $this->wp_customize;
115 115
 		unset($_wp_customize->nav_menus);
116 116
 
117 117
 		$exception = null;
118 118
 		try {
119
-			$bad_setting = new WP_Customize_Nav_Menu_Item_Setting( $_wp_customize, 'nav_menu_item[123]' );
120
-			unset( $bad_setting );
121
-		} catch ( Exception $e ) {
119
+			$bad_setting = new WP_Customize_Nav_Menu_Item_Setting($_wp_customize, 'nav_menu_item[123]');
120
+			unset($bad_setting);
121
+		} catch (Exception $e) {
122 122
 			$exception = $e;
123 123
 		}
124
-		$this->assertInstanceOf( 'Exception', $exception );
124
+		$this->assertInstanceOf('Exception', $exception);
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 * @see WP_Customize_Nav_Menu_Item_Setting::__construct()
131 131
 	 */
132 132
 	function test_construct_placeholder() {
133
-		do_action( 'customize_register', $this->wp_customize );
133
+		do_action('customize_register', $this->wp_customize);
134 134
 		$default = array(
135 135
 			'title' => 'Lorem',
136 136
 			'description' => 'ipsum',
137 137
 			'menu_item_parent' => 123,
138 138
 		);
139
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[-5]', compact( 'default' ) );
139
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[-5]', compact('default'));
140 140
 		$this->assertEquals( -5, $setting->post_id );
141
-		$this->assertNull( $setting->previous_post_id );
142
-		$this->assertEquals( $default, $setting->default );
141
+		$this->assertNull($setting->previous_post_id);
142
+		$this->assertEquals($default, $setting->default);
143 143
 	}
144 144
 
145 145
 	/**
@@ -148,41 +148,41 @@  discard block
 block discarded – undo
148 148
 	 * @see WP_Customize_Nav_Menu_Item_Setting::value()
149 149
 	 */
150 150
 	function test_value_type_post_type() {
151
-		do_action( 'customize_register', $this->wp_customize );
151
+		do_action('customize_register', $this->wp_customize);
152 152
 
153
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
153
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
154 154
 
155
-		$menu_id = wp_create_nav_menu( 'Menu' );
155
+		$menu_id = wp_create_nav_menu('Menu');
156 156
 		$item_title = 'Greetings';
157
-		$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
157
+		$item_id = wp_update_nav_menu_item($menu_id, 0, array(
158 158
 			'menu-item-type' => 'post_type',
159 159
 			'menu-item-object' => 'post',
160 160
 			'menu-item-object-id' => $post_id,
161 161
 			'menu-item-title' => $item_title,
162 162
 			'menu-item-status' => 'publish',
163
-		) );
163
+		));
164 164
 
165
-		$post = get_post( $item_id );
166
-		$menu_item = wp_setup_nav_menu_item( $post );
167
-		$this->assertEquals( $item_title, $menu_item->title );
165
+		$post = get_post($item_id);
166
+		$menu_item = wp_setup_nav_menu_item($post);
167
+		$this->assertEquals($item_title, $menu_item->title);
168 168
 
169 169
 		$setting_id = "nav_menu_item[$item_id]";
170
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
170
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
171 171
 
172 172
 		$value = $setting->value();
173
-		$this->assertEquals( $menu_item->title, $value['title'] );
174
-		$this->assertEquals( $menu_item->type, $value['type'] );
175
-		$this->assertEquals( $menu_item->object_id, $value['object_id'] );
176
-		$this->assertEquals( $menu_id, $value['nav_menu_term_id'] );
177
-		$this->assertEquals( 'Hello World', $value['original_title'] );
178
-
179
-		$other_menu_id = wp_create_nav_menu( 'Menu2' );
180
-		wp_update_nav_menu_item( $other_menu_id, $item_id, array(
173
+		$this->assertEquals($menu_item->title, $value['title']);
174
+		$this->assertEquals($menu_item->type, $value['type']);
175
+		$this->assertEquals($menu_item->object_id, $value['object_id']);
176
+		$this->assertEquals($menu_id, $value['nav_menu_term_id']);
177
+		$this->assertEquals('Hello World', $value['original_title']);
178
+
179
+		$other_menu_id = wp_create_nav_menu('Menu2');
180
+		wp_update_nav_menu_item($other_menu_id, $item_id, array(
181 181
 			'menu-item-title' => 'Hola',
182
-		) );
182
+		));
183 183
 		$value = $setting->value();
184
-		$this->assertEquals( 'Hola', $value['title'] );
185
-		$this->assertEquals( $other_menu_id, $value['nav_menu_term_id'] );
184
+		$this->assertEquals('Hola', $value['title']);
185
+		$this->assertEquals($other_menu_id, $value['nav_menu_term_id']);
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,33 +191,33 @@  discard block
 block discarded – undo
191 191
 	 * @see WP_Customize_Nav_Menu_Item_Setting::value()
192 192
 	 */
193 193
 	function test_value_type_taxonomy() {
194
-		do_action( 'customize_register', $this->wp_customize );
194
+		do_action('customize_register', $this->wp_customize);
195 195
 
196
-		$tax_id = $this->factory->category->create( array( 'name' => 'Salutations' ) );
196
+		$tax_id = $this->factory->category->create(array('name' => 'Salutations'));
197 197
 
198
-		$menu_id = wp_create_nav_menu( 'Menu' );
198
+		$menu_id = wp_create_nav_menu('Menu');
199 199
 		$item_title = 'Greetings';
200
-		$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
200
+		$item_id = wp_update_nav_menu_item($menu_id, 0, array(
201 201
 			'menu-item-type' => 'taxonomy',
202 202
 			'menu-item-object' => 'category',
203 203
 			'menu-item-object-id' => $tax_id,
204 204
 			'menu-item-title' => $item_title,
205 205
 			'menu-item-status' => 'publish',
206
-		) );
206
+		));
207 207
 
208
-		$post = get_post( $item_id );
209
-		$menu_item = wp_setup_nav_menu_item( $post );
210
-		$this->assertEquals( $item_title, $menu_item->title );
208
+		$post = get_post($item_id);
209
+		$menu_item = wp_setup_nav_menu_item($post);
210
+		$this->assertEquals($item_title, $menu_item->title);
211 211
 
212 212
 		$setting_id = "nav_menu_item[$item_id]";
213
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
213
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
214 214
 
215 215
 		$value = $setting->value();
216
-		$this->assertEquals( $menu_item->title, $value['title'] );
217
-		$this->assertEquals( $menu_item->type, $value['type'] );
218
-		$this->assertEquals( $menu_item->object_id, $value['object_id'] );
219
-		$this->assertEquals( $menu_id, $value['nav_menu_term_id'] );
220
-		$this->assertEquals( 'Salutations', $value['original_title'] );
216
+		$this->assertEquals($menu_item->title, $value['title']);
217
+		$this->assertEquals($menu_item->type, $value['type']);
218
+		$this->assertEquals($menu_item->object_id, $value['object_id']);
219
+		$this->assertEquals($menu_id, $value['nav_menu_term_id']);
220
+		$this->assertEquals('Salutations', $value['original_title']);
221 221
 	}
222 222
 
223 223
 	/**
@@ -226,26 +226,26 @@  discard block
 block discarded – undo
226 226
 	 * @see WP_Customize_Nav_Menu_Item_Setting::value()
227 227
 	 */
228 228
 	function test_custom_type_label() {
229
-		do_action( 'customize_register', $this->wp_customize );
230
-		add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
229
+		do_action('customize_register', $this->wp_customize);
230
+		add_filter('wp_setup_nav_menu_item', array($this, 'filter_type_label'));
231 231
 
232
-		$menu_id = wp_create_nav_menu( 'Menu' );
233
-		$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
232
+		$menu_id = wp_create_nav_menu('Menu');
233
+		$item_id = wp_update_nav_menu_item($menu_id, 0, array(
234 234
 			'menu-item-type'   => 'custom_type',
235 235
 			'menu-item-object' => 'custom_object',
236 236
 			'menu-item-title'  => 'Cool beans',
237 237
 			'menu-item-status' => 'publish',
238
-		) );
238
+		));
239 239
 
240
-		$post = get_post( $item_id );
241
-		$menu_item = wp_setup_nav_menu_item( $post );
240
+		$post = get_post($item_id);
241
+		$menu_item = wp_setup_nav_menu_item($post);
242 242
 
243 243
 		$setting_id = "nav_menu_item[$item_id]";
244
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
244
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
245 245
 
246 246
 		$value = $setting->value();
247
-		$this->assertEquals( $menu_item->type_label, 'Custom Label' );
248
-		$this->assertEquals( $menu_item->type_label, $value['type_label'] );
247
+		$this->assertEquals($menu_item->type_label, 'Custom Label');
248
+		$this->assertEquals($menu_item->type_label, $value['type_label']);
249 249
 	}
250 250
 
251 251
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 * @see WP_Customize_Nav_Menu_Item_Setting::value()
255 255
 	 */
256 256
 	function test_value_nav_menu_term_id_returns_zero() {
257
-		do_action( 'customize_register', $this->wp_customize );
257
+		do_action('customize_register', $this->wp_customize);
258 258
 
259 259
 		$menu_id = -123;
260 260
 		$post_value = array(
@@ -264,29 +264,29 @@  discard block
 block discarded – undo
264 264
 			'auto_add' => false,
265 265
 		);
266 266
 		$setting_id = "nav_menu[$menu_id]";
267
-		$menu = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
267
+		$menu = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
268 268
 
269
-		$this->wp_customize->set_post_value( $menu->id, $post_value );
269
+		$this->wp_customize->set_post_value($menu->id, $post_value);
270 270
 		$menu->preview();
271 271
 		$value = $menu->value();
272
-		$this->assertEquals( $post_value, $value );
272
+		$this->assertEquals($post_value, $value);
273 273
 
274
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
275
-		$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
274
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
275
+		$item_id = wp_update_nav_menu_item($menu_id, 0, array(
276 276
 			'menu-item-type' => 'post_type',
277 277
 			'menu-item-object' => 'post',
278 278
 			'menu-item-object-id' => $post_id,
279 279
 			'menu-item-title' => 'Hello World',
280 280
 			'menu-item-status' => 'publish',
281
-		) );
281
+		));
282 282
 
283
-		$post = get_post( $item_id );
284
-		$menu_item = wp_setup_nav_menu_item( $post );
283
+		$post = get_post($item_id);
284
+		$menu_item = wp_setup_nav_menu_item($post);
285 285
 
286 286
 		$setting_id = "nav_menu_item[$item_id]";
287
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
287
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
288 288
 		$value = $setting->value();
289
-		$this->assertEquals( 0, $value['nav_menu_term_id'] );
289
+		$this->assertEquals(0, $value['nav_menu_term_id']);
290 290
 	}
291 291
 
292 292
 	/**
@@ -295,22 +295,22 @@  discard block
 block discarded – undo
295 295
 	 * @see WP_Customize_Nav_Menu_Item_Setting::preview()
296 296
 	 */
297 297
 	function test_preview_updated() {
298
-		do_action( 'customize_register', $this->wp_customize );
298
+		do_action('customize_register', $this->wp_customize);
299 299
 
300
-		$first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
301
-		$second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) );
300
+		$first_post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
301
+		$second_post_id = $this->factory->post->create(array('post_title' => 'Hola Muno'));
302 302
 
303
-		$primary_menu_id = wp_create_nav_menu( 'Primary' );
304
-		$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
303
+		$primary_menu_id = wp_create_nav_menu('Primary');
304
+		$secondary_menu_id = wp_create_nav_menu('Secondary');
305 305
 		$item_title = 'Greetings';
306
-		$item_id = wp_update_nav_menu_item( $primary_menu_id, 0, array(
306
+		$item_id = wp_update_nav_menu_item($primary_menu_id, 0, array(
307 307
 			'menu-item-type' => 'post_type',
308 308
 			'menu-item-object' => 'post',
309 309
 			'menu-item-object-id' => $first_post_id,
310 310
 			'menu-item-title' => $item_title,
311 311
 			'menu-item-status' => 'publish',
312
-		) );
313
-		$this->assertNotEmpty( wp_get_nav_menu_items( $primary_menu_id, array( 'post_status' => 'publish,draft' ) ) );
312
+		));
313
+		$this->assertNotEmpty(wp_get_nav_menu_items($primary_menu_id, array('post_status' => 'publish,draft')));
314 314
 
315 315
 		$post_value = array(
316 316
 			'type' => 'post_type',
@@ -321,22 +321,22 @@  discard block
 block discarded – undo
321 321
 			'nav_menu_term_id' => $secondary_menu_id,
322 322
 		);
323 323
 		$setting_id = "nav_menu_item[$item_id]";
324
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
325
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
326
-		unset( $post_value['nav_menu_term_id'] );
324
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
325
+		$this->wp_customize->set_post_value($setting_id, $post_value);
326
+		unset($post_value['nav_menu_term_id']);
327 327
 		$setting->preview();
328 328
 
329 329
 		// Make sure the menu item appears in the new menu.
330
-		$this->assertNotContains( $item_id, wp_list_pluck( wp_get_nav_menu_items( $primary_menu_id ), 'db_id' ) );
331
-		$menu_items = wp_get_nav_menu_items( $secondary_menu_id );
332
-		$db_ids = wp_list_pluck( $menu_items, 'db_id' );
333
-		$this->assertContains( $item_id, $db_ids );
334
-		$i = array_search( $item_id, $db_ids );
335
-		$updated_item = $menu_items[ $i ];
330
+		$this->assertNotContains($item_id, wp_list_pluck(wp_get_nav_menu_items($primary_menu_id), 'db_id'));
331
+		$menu_items = wp_get_nav_menu_items($secondary_menu_id);
332
+		$db_ids = wp_list_pluck($menu_items, 'db_id');
333
+		$this->assertContains($item_id, $db_ids);
334
+		$i = array_search($item_id, $db_ids);
335
+		$updated_item = $menu_items[$i];
336 336
 		$post_value['post_status'] = $post_value['status'];
337
-		unset( $post_value['status'] );
338
-		foreach ( $post_value as $key => $value ) {
339
-			$this->assertEquals( $value, $updated_item->$key, "Key $key mismatch" );
337
+		unset($post_value['status']);
338
+		foreach ($post_value as $key => $value) {
339
+			$this->assertEquals($value, $updated_item->$key, "Key $key mismatch");
340 340
 		}
341 341
 	}
342 342
 
@@ -346,20 +346,20 @@  discard block
 block discarded – undo
346 346
 	 * @see WP_Customize_Nav_Menu_Item_Setting::preview()
347 347
 	 */
348 348
 	function test_preview_inserted() {
349
-		do_action( 'customize_register', $this->wp_customize );
349
+		do_action('customize_register', $this->wp_customize);
350 350
 
351
-		$menu_id = wp_create_nav_menu( 'Primary' );
352
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
351
+		$menu_id = wp_create_nav_menu('Primary');
352
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
353 353
 		$item_ids = array();
354
-		for ( $i = 0; $i < 5; $i += 1 ) {
355
-			$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
354
+		for ($i = 0; $i < 5; $i += 1) {
355
+			$item_id = wp_update_nav_menu_item($menu_id, 0, array(
356 356
 				'menu-item-type' => 'post_type',
357 357
 				'menu-item-object' => 'post',
358 358
 				'menu-item-object-id' => $post_id,
359 359
 				'menu-item-title' => "Item $i",
360 360
 				'menu-item-status' => 'publish',
361 361
 				'menu-item-position' => $i + 1,
362
-			) );
362
+			));
363 363
 			$item_ids[] = $item_id;
364 364
 		}
365 365
 
@@ -370,28 +370,28 @@  discard block
 block discarded – undo
370 370
 			'title' => 'Inserted item',
371 371
 			'status' => 'publish',
372 372
 			'nav_menu_term_id' => $menu_id,
373
-			'position' => count( $item_ids ) + 1,
373
+			'position' => count($item_ids) + 1,
374 374
 		);
375 375
 
376 376
 		$new_item_id = -10;
377 377
 		$setting_id = "nav_menu_item[$new_item_id]";
378
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
379
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
380
-		unset( $post_value['nav_menu_term_id'] );
378
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
379
+		$this->wp_customize->set_post_value($setting_id, $post_value);
380
+		unset($post_value['nav_menu_term_id']);
381 381
 
382
-		$current_items = wp_get_nav_menu_items( $menu_id );
382
+		$current_items = wp_get_nav_menu_items($menu_id);
383 383
 		$setting->preview();
384
-		$preview_items = wp_get_nav_menu_items( $menu_id );
385
-		$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
384
+		$preview_items = wp_get_nav_menu_items($menu_id);
385
+		$this->assertNotEquals(count($current_items), count($preview_items));
386 386
 
387
-		$last_item = array_pop( $preview_items );
388
-		$this->assertEquals( $new_item_id, $last_item->db_id );
387
+		$last_item = array_pop($preview_items);
388
+		$this->assertEquals($new_item_id, $last_item->db_id);
389 389
 		$post_value['post_status'] = $post_value['status'];
390
-		unset( $post_value['status'] );
390
+		unset($post_value['status']);
391 391
 		$post_value['menu_order'] = $post_value['position'];
392
-		unset( $post_value['position'] );
393
-		foreach ( $post_value as $key => $value ) {
394
-			$this->assertEquals( $value, $last_item->$key, "Mismatch for $key property." );
392
+		unset($post_value['position']);
393
+		foreach ($post_value as $key => $value) {
394
+			$this->assertEquals($value, $last_item->$key, "Mismatch for $key property.");
395 395
 		}
396 396
 	}
397 397
 
@@ -401,34 +401,34 @@  discard block
 block discarded – undo
401 401
 	 * @see WP_Customize_Nav_Menu_Item_Setting::preview()
402 402
 	 */
403 403
 	function test_preview_deleted() {
404
-		do_action( 'customize_register', $this->wp_customize );
404
+		do_action('customize_register', $this->wp_customize);
405 405
 
406
-		$menu_id = wp_create_nav_menu( 'Primary' );
407
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
406
+		$menu_id = wp_create_nav_menu('Primary');
407
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
408 408
 		$item_ids = array();
409
-		for ( $i = 0; $i < 5; $i += 1 ) {
410
-			$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
409
+		for ($i = 0; $i < 5; $i += 1) {
410
+			$item_id = wp_update_nav_menu_item($menu_id, 0, array(
411 411
 				'menu-item-type' => 'post_type',
412 412
 				'menu-item-object' => 'post',
413 413
 				'menu-item-object-id' => $post_id,
414 414
 				'menu-item-title' => "Item $i",
415 415
 				'menu-item-status' => 'publish',
416 416
 				'menu-item-position' => $i + 1,
417
-			) );
417
+			));
418 418
 			$item_ids[] = $item_id;
419 419
 		}
420 420
 
421 421
 		$delete_item_id = $item_ids[2];
422 422
 		$setting_id = "nav_menu_item[$delete_item_id]";
423
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
424
-		$this->wp_customize->set_post_value( $setting_id, false );
423
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
424
+		$this->wp_customize->set_post_value($setting_id, false);
425 425
 
426
-		$current_items = wp_get_nav_menu_items( $menu_id );
427
-		$this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
426
+		$current_items = wp_get_nav_menu_items($menu_id);
427
+		$this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id'));
428 428
 		$setting->preview();
429
-		$preview_items = wp_get_nav_menu_items( $menu_id );
430
-		$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
431
-		$this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
429
+		$preview_items = wp_get_nav_menu_items($menu_id);
430
+		$this->assertNotEquals(count($current_items), count($preview_items));
431
+		$this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id'));
432 432
 	}
433 433
 
434 434
 	/**
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	 * @see WP_Customize_Nav_Menu_Item_Setting::sanitize()
438 438
 	 */
439 439
 	function test_sanitize() {
440
-		do_action( 'customize_register', $this->wp_customize );
441
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' );
440
+		do_action('customize_register', $this->wp_customize);
441
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, 'nav_menu_item[123]');
442 442
 
443
-		$this->assertNull( $setting->sanitize( 'not an array' ) );
444
-		$this->assertNull( $setting->sanitize( 123 ) );
443
+		$this->assertNull($setting->sanitize('not an array'));
444
+		$this->assertNull($setting->sanitize(123));
445 445
 
446 446
 		$unsanitized = array(
447 447
 			'object_id' => 'bad',
@@ -461,24 +461,24 @@  discard block
 block discarded – undo
461 461
 			'nav_menu_term_id' => 'heilo',
462 462
 		);
463 463
 
464
-		$sanitized = $setting->sanitize( $unsanitized );
465
-		$this->assertEqualSets( array_keys( $unsanitized ), array_keys( $sanitized ) );
466
-
467
-		$this->assertEquals( 0, $sanitized['object_id'] );
468
-		$this->assertEquals( 'bhellob', $sanitized['object'] );
469
-		$this->assertEquals( 0, $sanitized['menu_item_parent'] );
470
-		$this->assertEquals( 0, $sanitized['position'] );
471
-		$this->assertEquals( 'customb', $sanitized['type'] );
472
-		$this->assertEquals( 'Hi', $sanitized['title'] );
473
-		$this->assertEquals( '', $sanitized['url'] );
474
-		$this->assertEquals( 'onclick', $sanitized['target'] );
475
-		$this->assertEquals( 'evil', $sanitized['attr_title'] );
476
-		$this->assertEquals( 'Hello world', $sanitized['description'] );
477
-		$this->assertEquals( 'hello  inject', $sanitized['classes'] );
478
-		$this->assertEquals( 'hello  inject', $sanitized['xfn'] );
479
-		$this->assertEquals( 'publish', $sanitized['status'] );
480
-		$this->assertEquals( 'Hi', $sanitized['original_title'] );
481
-		$this->assertEquals( 0, $sanitized['nav_menu_term_id'] );
464
+		$sanitized = $setting->sanitize($unsanitized);
465
+		$this->assertEqualSets(array_keys($unsanitized), array_keys($sanitized));
466
+
467
+		$this->assertEquals(0, $sanitized['object_id']);
468
+		$this->assertEquals('bhellob', $sanitized['object']);
469
+		$this->assertEquals(0, $sanitized['menu_item_parent']);
470
+		$this->assertEquals(0, $sanitized['position']);
471
+		$this->assertEquals('customb', $sanitized['type']);
472
+		$this->assertEquals('Hi', $sanitized['title']);
473
+		$this->assertEquals('', $sanitized['url']);
474
+		$this->assertEquals('onclick', $sanitized['target']);
475
+		$this->assertEquals('evil', $sanitized['attr_title']);
476
+		$this->assertEquals('Hello world', $sanitized['description']);
477
+		$this->assertEquals('hello  inject', $sanitized['classes']);
478
+		$this->assertEquals('hello  inject', $sanitized['xfn']);
479
+		$this->assertEquals('publish', $sanitized['status']);
480
+		$this->assertEquals('Hi', $sanitized['original_title']);
481
+		$this->assertEquals(0, $sanitized['nav_menu_term_id']);
482 482
 	}
483 483
 
484 484
 	/**
@@ -487,22 +487,22 @@  discard block
 block discarded – undo
487 487
 	 * @see WP_Customize_Nav_Menu_Item_Setting::update()
488 488
 	 */
489 489
 	function test_save_updated() {
490
-		do_action( 'customize_register', $this->wp_customize );
490
+		do_action('customize_register', $this->wp_customize);
491 491
 
492
-		$first_post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
493
-		$second_post_id = $this->factory->post->create( array( 'post_title' => 'Hola Muno' ) );
492
+		$first_post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
493
+		$second_post_id = $this->factory->post->create(array('post_title' => 'Hola Muno'));
494 494
 
495
-		$primary_menu_id = wp_create_nav_menu( 'Primary' );
496
-		$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
495
+		$primary_menu_id = wp_create_nav_menu('Primary');
496
+		$secondary_menu_id = wp_create_nav_menu('Secondary');
497 497
 		$item_title = 'Greetings';
498
-		$item_id = wp_update_nav_menu_item( $primary_menu_id, 0, array(
498
+		$item_id = wp_update_nav_menu_item($primary_menu_id, 0, array(
499 499
 			'menu-item-type' => 'post_type',
500 500
 			'menu-item-object' => 'post',
501 501
 			'menu-item-object-id' => $first_post_id,
502 502
 			'menu-item-title' => $item_title,
503 503
 			'menu-item-status' => 'publish',
504
-		) );
505
-		$this->assertNotEmpty( wp_get_nav_menu_items( $primary_menu_id, array( 'post_status' => 'publish,draft' ) ) );
504
+		));
505
+		$this->assertNotEmpty(wp_get_nav_menu_items($primary_menu_id, array('post_status' => 'publish,draft')));
506 506
 
507 507
 		$post_value = array(
508 508
 			'type' => 'post_type',
@@ -513,37 +513,37 @@  discard block
 block discarded – undo
513 513
 			'nav_menu_term_id' => $secondary_menu_id,
514 514
 		);
515 515
 		$setting_id = "nav_menu_item[$item_id]";
516
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
517
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
518
-		unset( $post_value['nav_menu_term_id'] );
516
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
517
+		$this->wp_customize->set_post_value($setting_id, $post_value);
518
+		unset($post_value['nav_menu_term_id']);
519 519
 		$setting->save();
520 520
 
521 521
 		// Make sure the menu item appears in the new menu.
522
-		$this->assertNotContains( $item_id, wp_list_pluck( wp_get_nav_menu_items( $primary_menu_id ), 'db_id' ) );
523
-		$menu_items = wp_get_nav_menu_items( $secondary_menu_id );
524
-		$db_ids = wp_list_pluck( $menu_items, 'db_id' );
525
-		$this->assertContains( $item_id, $db_ids );
526
-		$i = array_search( $item_id, $db_ids );
527
-		$updated_item = $menu_items[ $i ];
522
+		$this->assertNotContains($item_id, wp_list_pluck(wp_get_nav_menu_items($primary_menu_id), 'db_id'));
523
+		$menu_items = wp_get_nav_menu_items($secondary_menu_id);
524
+		$db_ids = wp_list_pluck($menu_items, 'db_id');
525
+		$this->assertContains($item_id, $db_ids);
526
+		$i = array_search($item_id, $db_ids);
527
+		$updated_item = $menu_items[$i];
528 528
 		$post_value['post_status'] = $post_value['status'];
529
-		unset( $post_value['status'] );
530
-		foreach ( $post_value as $key => $value ) {
531
-			$this->assertEquals( $value, $updated_item->$key, "Key $key mismatch" );
529
+		unset($post_value['status']);
530
+		foreach ($post_value as $key => $value) {
531
+			$this->assertEquals($value, $updated_item->$key, "Key $key mismatch");
532 532
 		}
533 533
 
534 534
 		// Verify the Ajax responses is being amended.
535
-		$save_response = apply_filters( 'customize_save_response', array() );
536
-		$this->assertArrayHasKey( 'nav_menu_item_updates', $save_response );
537
-		$update_result = array_shift( $save_response['nav_menu_item_updates'] );
538
-		$this->assertArrayHasKey( 'post_id', $update_result );
539
-		$this->assertArrayHasKey( 'previous_post_id', $update_result );
540
-		$this->assertArrayHasKey( 'error', $update_result );
541
-		$this->assertArrayHasKey( 'status', $update_result );
542
-
543
-		$this->assertEquals( $item_id, $update_result['post_id'] );
544
-		$this->assertNull( $update_result['previous_post_id'] );
545
-		$this->assertNull( $update_result['error'] );
546
-		$this->assertEquals( 'updated', $update_result['status'] );
535
+		$save_response = apply_filters('customize_save_response', array());
536
+		$this->assertArrayHasKey('nav_menu_item_updates', $save_response);
537
+		$update_result = array_shift($save_response['nav_menu_item_updates']);
538
+		$this->assertArrayHasKey('post_id', $update_result);
539
+		$this->assertArrayHasKey('previous_post_id', $update_result);
540
+		$this->assertArrayHasKey('error', $update_result);
541
+		$this->assertArrayHasKey('status', $update_result);
542
+
543
+		$this->assertEquals($item_id, $update_result['post_id']);
544
+		$this->assertNull($update_result['previous_post_id']);
545
+		$this->assertNull($update_result['error']);
546
+		$this->assertEquals('updated', $update_result['status']);
547 547
 	}
548 548
 
549 549
 	/**
@@ -552,20 +552,20 @@  discard block
 block discarded – undo
552 552
 	 * @see WP_Customize_Nav_Menu_Item_Setting::update()
553 553
 	 */
554 554
 	function test_save_inserted() {
555
-		do_action( 'customize_register', $this->wp_customize );
555
+		do_action('customize_register', $this->wp_customize);
556 556
 
557
-		$menu_id = wp_create_nav_menu( 'Primary' );
558
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
557
+		$menu_id = wp_create_nav_menu('Primary');
558
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
559 559
 		$item_ids = array();
560
-		for ( $i = 0; $i < 5; $i += 1 ) {
561
-			$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
560
+		for ($i = 0; $i < 5; $i += 1) {
561
+			$item_id = wp_update_nav_menu_item($menu_id, 0, array(
562 562
 				'menu-item-type' => 'post_type',
563 563
 				'menu-item-object' => 'post',
564 564
 				'menu-item-object-id' => $post_id,
565 565
 				'menu-item-title' => "Item $i",
566 566
 				'menu-item-status' => 'publish',
567 567
 				'menu-item-position' => $i + 1,
568
-			) );
568
+			));
569 569
 			$item_ids[] = $item_id;
570 570
 		}
571 571
 
@@ -576,43 +576,43 @@  discard block
 block discarded – undo
576 576
 			'title' => 'Inserted item',
577 577
 			'status' => 'publish',
578 578
 			'nav_menu_term_id' => $menu_id,
579
-			'position' => count( $item_ids ) + 1,
579
+			'position' => count($item_ids) + 1,
580 580
 		);
581 581
 
582 582
 		$new_item_id = -10;
583 583
 		$setting_id = "nav_menu_item[$new_item_id]";
584
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
585
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
586
-		unset( $post_value['nav_menu_term_id'] );
584
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
585
+		$this->wp_customize->set_post_value($setting_id, $post_value);
586
+		unset($post_value['nav_menu_term_id']);
587 587
 
588
-		$current_items = wp_get_nav_menu_items( $menu_id );
588
+		$current_items = wp_get_nav_menu_items($menu_id);
589 589
 		$setting->save();
590
-		$preview_items = wp_get_nav_menu_items( $menu_id );
591
-		$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
590
+		$preview_items = wp_get_nav_menu_items($menu_id);
591
+		$this->assertNotEquals(count($current_items), count($preview_items));
592 592
 
593
-		$last_item = array_pop( $preview_items );
594
-		$this->assertEquals( $setting->post_id, $last_item->db_id );
593
+		$last_item = array_pop($preview_items);
594
+		$this->assertEquals($setting->post_id, $last_item->db_id);
595 595
 		$post_value['post_status'] = $post_value['status'];
596
-		unset( $post_value['status'] );
596
+		unset($post_value['status']);
597 597
 		$post_value['menu_order'] = $post_value['position'];
598
-		unset( $post_value['position'] );
599
-		foreach ( $post_value as $key => $value ) {
600
-			$this->assertEquals( $value, $last_item->$key, "Mismatch for $key property." );
598
+		unset($post_value['position']);
599
+		foreach ($post_value as $key => $value) {
600
+			$this->assertEquals($value, $last_item->$key, "Mismatch for $key property.");
601 601
 		}
602 602
 
603 603
 		// Verify the Ajax responses is being amended.
604
-		$save_response = apply_filters( 'customize_save_response', array() );
605
-		$this->assertArrayHasKey( 'nav_menu_item_updates', $save_response );
606
-		$update_result = array_shift( $save_response['nav_menu_item_updates'] );
607
-		$this->assertArrayHasKey( 'post_id', $update_result );
608
-		$this->assertArrayHasKey( 'previous_post_id', $update_result );
609
-		$this->assertArrayHasKey( 'error', $update_result );
610
-		$this->assertArrayHasKey( 'status', $update_result );
611
-
612
-		$this->assertEquals( $setting->post_id, $update_result['post_id'] );
613
-		$this->assertEquals( $new_item_id, $update_result['previous_post_id'] );
614
-		$this->assertNull( $update_result['error'] );
615
-		$this->assertEquals( 'inserted', $update_result['status'] );
604
+		$save_response = apply_filters('customize_save_response', array());
605
+		$this->assertArrayHasKey('nav_menu_item_updates', $save_response);
606
+		$update_result = array_shift($save_response['nav_menu_item_updates']);
607
+		$this->assertArrayHasKey('post_id', $update_result);
608
+		$this->assertArrayHasKey('previous_post_id', $update_result);
609
+		$this->assertArrayHasKey('error', $update_result);
610
+		$this->assertArrayHasKey('status', $update_result);
611
+
612
+		$this->assertEquals($setting->post_id, $update_result['post_id']);
613
+		$this->assertEquals($new_item_id, $update_result['previous_post_id']);
614
+		$this->assertNull($update_result['error']);
615
+		$this->assertEquals('inserted', $update_result['status']);
616 616
 	}
617 617
 
618 618
 	/**
@@ -621,48 +621,48 @@  discard block
 block discarded – undo
621 621
 	 * @see WP_Customize_Nav_Menu_Item_Setting::update()
622 622
 	 */
623 623
 	function test_save_deleted() {
624
-		do_action( 'customize_register', $this->wp_customize );
624
+		do_action('customize_register', $this->wp_customize);
625 625
 
626
-		$menu_id = wp_create_nav_menu( 'Primary' );
627
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
626
+		$menu_id = wp_create_nav_menu('Primary');
627
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
628 628
 		$item_ids = array();
629
-		for ( $i = 0; $i < 5; $i += 1 ) {
630
-			$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
629
+		for ($i = 0; $i < 5; $i += 1) {
630
+			$item_id = wp_update_nav_menu_item($menu_id, 0, array(
631 631
 				'menu-item-type' => 'post_type',
632 632
 				'menu-item-object' => 'post',
633 633
 				'menu-item-object-id' => $post_id,
634 634
 				'menu-item-title' => "Item $i",
635 635
 				'menu-item-status' => 'publish',
636 636
 				'menu-item-position' => $i + 1,
637
-			) );
637
+			));
638 638
 			$item_ids[] = $item_id;
639 639
 		}
640 640
 
641 641
 		$delete_item_id = $item_ids[2];
642 642
 		$setting_id = "nav_menu_item[$delete_item_id]";
643
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
644
-		$this->wp_customize->set_post_value( $setting_id, false );
643
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, $setting_id);
644
+		$this->wp_customize->set_post_value($setting_id, false);
645 645
 
646
-		$current_items = wp_get_nav_menu_items( $menu_id );
647
-		$this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
646
+		$current_items = wp_get_nav_menu_items($menu_id);
647
+		$this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id'));
648 648
 		$setting->save();
649
-		$preview_items = wp_get_nav_menu_items( $menu_id );
650
-		$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
651
-		$this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
649
+		$preview_items = wp_get_nav_menu_items($menu_id);
650
+		$this->assertNotEquals(count($current_items), count($preview_items));
651
+		$this->assertContains($delete_item_id, wp_list_pluck($current_items, 'db_id'));
652 652
 
653 653
 		// Verify the Ajax responses is being amended.
654
-		$save_response = apply_filters( 'customize_save_response', array() );
655
-		$this->assertArrayHasKey( 'nav_menu_item_updates', $save_response );
656
-		$update_result = array_shift( $save_response['nav_menu_item_updates'] );
657
-		$this->assertArrayHasKey( 'post_id', $update_result );
658
-		$this->assertArrayHasKey( 'previous_post_id', $update_result );
659
-		$this->assertArrayHasKey( 'error', $update_result );
660
-		$this->assertArrayHasKey( 'status', $update_result );
661
-
662
-		$this->assertEquals( $delete_item_id, $update_result['post_id'] );
663
-		$this->assertNull( $update_result['previous_post_id'] );
664
-		$this->assertNull( $update_result['error'] );
665
-		$this->assertEquals( 'deleted', $update_result['status'] );
654
+		$save_response = apply_filters('customize_save_response', array());
655
+		$this->assertArrayHasKey('nav_menu_item_updates', $save_response);
656
+		$update_result = array_shift($save_response['nav_menu_item_updates']);
657
+		$this->assertArrayHasKey('post_id', $update_result);
658
+		$this->assertArrayHasKey('previous_post_id', $update_result);
659
+		$this->assertArrayHasKey('error', $update_result);
660
+		$this->assertArrayHasKey('status', $update_result);
661
+
662
+		$this->assertEquals($delete_item_id, $update_result['post_id']);
663
+		$this->assertNull($update_result['previous_post_id']);
664
+		$this->assertNull($update_result['error']);
665
+		$this->assertEquals('deleted', $update_result['status']);
666 666
 	}
667 667
 
668 668
 }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Tests WP_Customize_Nav_Menu_Item_Setting.
4
- *
5
- * @group customize
6
- */
3
+	 * Tests WP_Customize_Nav_Menu_Item_Setting.
4
+	 *
5
+	 * @group customize
6
+	 */
7 7
 class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
8 8
 
9 9
 	/**
Please login to merge, or discard this patch.
tests/core/panel.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 	function setUp() {
16 16
 		parent::setUp();
17
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
17
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
18 18
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
19 19
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
20 20
 		$this->manager = $GLOBALS['wp_customize'];
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 	function tearDown() {
25 25
 		$this->manager = null;
26
-		unset( $GLOBALS['wp_customize'] );
26
+		unset($GLOBALS['wp_customize']);
27 27
 		parent::tearDown();
28 28
 	}
29 29
 
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 	 * @see WP_Customize_Panel::__construct()
32 32
 	 */
33 33
 	function test_construct_default_args() {
34
-		$panel = new WP_Customize_Panel( $this->manager, 'foo' );
35
-		$this->assertInternalType( 'int', $panel->instance_number );
36
-		$this->assertEquals( $this->manager, $panel->manager );
37
-		$this->assertEquals( 'foo', $panel->id );
38
-		$this->assertEquals( 160, $panel->priority );
39
-		$this->assertEquals( 'edit_theme_options', $panel->capability );
40
-		$this->assertEquals( '', $panel->theme_supports );
41
-		$this->assertEquals( '', $panel->title );
42
-		$this->assertEquals( '', $panel->description );
43
-		$this->assertEmpty( $panel->sections );
44
-		$this->assertEquals( 'default', $panel->type );
45
-		$this->assertEquals( array( $panel, 'active_callback' ), $panel->active_callback );
34
+		$panel = new WP_Customize_Panel($this->manager, 'foo');
35
+		$this->assertInternalType('int', $panel->instance_number);
36
+		$this->assertEquals($this->manager, $panel->manager);
37
+		$this->assertEquals('foo', $panel->id);
38
+		$this->assertEquals(160, $panel->priority);
39
+		$this->assertEquals('edit_theme_options', $panel->capability);
40
+		$this->assertEquals('', $panel->theme_supports);
41
+		$this->assertEquals('', $panel->title);
42
+		$this->assertEquals('', $panel->description);
43
+		$this->assertEmpty($panel->sections);
44
+		$this->assertEquals('default', $panel->type);
45
+		$this->assertEquals(array($panel, 'active_callback'), $panel->active_callback);
46 46
 	}
47 47
 
48 48
 	/**
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 			'active_callback' => '__return_true',
60 60
 		);
61 61
 
62
-		$panel = new WP_Customize_Panel( $this->manager, 'foo', $args );
63
-		foreach ( $args as $key => $value ) {
64
-			$this->assertEquals( $value, $panel->$key );
62
+		$panel = new WP_Customize_Panel($this->manager, 'foo', $args);
63
+		foreach ($args as $key => $value) {
64
+			$this->assertEquals($value, $panel->$key);
65 65
 		}
66 66
 	}
67 67
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 * @see WP_Customize_Panel::__construct()
70 70
 	 */
71 71
 	function test_construct_custom_type() {
72
-		$panel = new Custom_Panel_Test( $this->manager, 'foo' );
73
-		$this->assertEquals( 'titleless', $panel->type );
72
+		$panel = new Custom_Panel_Test($this->manager, 'foo');
73
+		$this->assertEquals('titleless', $panel->type);
74 74
 	}
75 75
 
76 76
 	/**
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @see WP_Customize_Panel::active_callback()
79 79
 	 */
80 80
 	function test_active() {
81
-		$panel = new WP_Customize_Panel( $this->manager, 'foo' );
82
-		$this->assertTrue( $panel->active() );
81
+		$panel = new WP_Customize_Panel($this->manager, 'foo');
82
+		$this->assertTrue($panel->active());
83 83
 
84
-		$panel = new WP_Customize_Panel( $this->manager, 'foo', array(
84
+		$panel = new WP_Customize_Panel($this->manager, 'foo', array(
85 85
 			'active_callback' => '__return_false',
86
-		) );
87
-		$this->assertFalse( $panel->active() );
88
-		add_filter( 'customize_panel_active', array( $this, 'filter_active_test' ), 10, 2 );
89
-		$this->assertTrue( $panel->active() );
86
+		));
87
+		$this->assertFalse($panel->active());
88
+		add_filter('customize_panel_active', array($this, 'filter_active_test'), 10, 2);
89
+		$this->assertTrue($panel->active());
90 90
 	}
91 91
 
92 92
 	/**
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param WP_Customize_Panel $panel
95 95
 	 * @return bool
96 96
 	 */
97
-	function filter_active_test( $active, $panel ) {
98
-		$this->assertFalse( $active );
99
-		$this->assertInstanceOf( 'WP_Customize_Panel', $panel );
97
+	function filter_active_test($active, $panel) {
98
+		$this->assertFalse($active);
99
+		$this->assertInstanceOf('WP_Customize_Panel', $panel);
100 100
 		$active = true;
101 101
 		return $active;
102 102
 	}
@@ -114,105 +114,105 @@  discard block
 block discarded – undo
114 114
 			'type' => 'horizontal',
115 115
 			'active_callback' => '__return_true',
116 116
 		);
117
-		$panel = new WP_Customize_Panel( $this->manager, 'foo', $args );
117
+		$panel = new WP_Customize_Panel($this->manager, 'foo', $args);
118 118
 		$data = $panel->json();
119
-		$this->assertEquals( 'foo', $data['id'] );
120
-		foreach ( array( 'title', 'description', 'priority', 'type' ) as $key ) {
121
-			$this->assertEquals( $args[ $key ], $data[ $key ] );
119
+		$this->assertEquals('foo', $data['id']);
120
+		foreach (array('title', 'description', 'priority', 'type') as $key) {
121
+			$this->assertEquals($args[$key], $data[$key]);
122 122
 		}
123
-		$this->assertEmpty( $data['content'] );
124
-		$this->assertTrue( $data['active'] );
125
-		$this->assertInternalType( 'int', $data['instanceNumber'] );
123
+		$this->assertEmpty($data['content']);
124
+		$this->assertTrue($data['active']);
125
+		$this->assertInternalType('int', $data['instanceNumber']);
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * @see WP_Customize_Panel::check_capabilities()
130 130
 	 */
131 131
 	function test_check_capabilities() {
132
-		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
133
-		wp_set_current_user( $user_id );
132
+		$user_id = $this->factory->user->create(array('role' => 'administrator'));
133
+		wp_set_current_user($user_id);
134 134
 
135
-		$panel = new WP_Customize_Panel( $this->manager, 'foo' );
136
-		$this->assertTrue( $panel->check_capabilities() );
135
+		$panel = new WP_Customize_Panel($this->manager, 'foo');
136
+		$this->assertTrue($panel->check_capabilities());
137 137
 		$old_cap = $panel->capability;
138 138
 		$panel->capability = 'do_not_allow';
139
-		$this->assertFalse( $panel->check_capabilities() );
139
+		$this->assertFalse($panel->check_capabilities());
140 140
 		$panel->capability = $old_cap;
141
-		$this->assertTrue( $panel->check_capabilities() );
141
+		$this->assertTrue($panel->check_capabilities());
142 142
 		$panel->theme_supports = 'impossible_feature';
143
-		$this->assertFalse( $panel->check_capabilities() );
143
+		$this->assertFalse($panel->check_capabilities());
144 144
 	}
145 145
 
146 146
 	/**
147 147
 	 * @see WP_Customize_Panel::get_content()
148 148
 	 */
149 149
 	function test_get_content() {
150
-		$panel = new WP_Customize_Panel( $this->manager, 'foo' );
151
-		$this->assertEmpty( $panel->get_content() );
150
+		$panel = new WP_Customize_Panel($this->manager, 'foo');
151
+		$this->assertEmpty($panel->get_content());
152 152
 	}
153 153
 
154 154
 	/**
155 155
 	 * @see WP_Customize_Panel::maybe_render()
156 156
 	 */
157 157
 	function test_maybe_render() {
158
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
159
-		$panel = new WP_Customize_Panel( $this->manager, 'bar' );
160
-		$customize_render_panel_count = did_action( 'customize_render_panel' );
161
-		add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) );
158
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
159
+		$panel = new WP_Customize_Panel($this->manager, 'bar');
160
+		$customize_render_panel_count = did_action('customize_render_panel');
161
+		add_action('customize_render_panel', array($this, 'action_customize_render_panel_test'));
162 162
 		ob_start();
163 163
 		$panel->maybe_render();
164 164
 		$content = ob_get_clean();
165
-		$this->assertTrue( $panel->check_capabilities() );
166
-		$this->assertEmpty( $content );
167
-		$this->assertEquals( $customize_render_panel_count + 1, did_action( 'customize_render_panel' ), 'Unexpected did_action count for customize_render_panel' );
168
-		$this->assertEquals( 1, did_action( "customize_render_panel_{$panel->id}" ), "Unexpected did_action count for customize_render_panel_{$panel->id}" );
165
+		$this->assertTrue($panel->check_capabilities());
166
+		$this->assertEmpty($content);
167
+		$this->assertEquals($customize_render_panel_count + 1, did_action('customize_render_panel'), 'Unexpected did_action count for customize_render_panel');
168
+		$this->assertEquals(1, did_action("customize_render_panel_{$panel->id}"), "Unexpected did_action count for customize_render_panel_{$panel->id}");
169 169
 	}
170 170
 
171 171
 	/**
172 172
 	 * @see WP_Customize_Panel::maybe_render()
173 173
 	 * @param WP_Customize_Panel $panel
174 174
 	 */
175
-	function action_customize_render_panel_test( $panel ) {
176
-		$this->assertInstanceOf( 'WP_Customize_Panel', $panel );
175
+	function action_customize_render_panel_test($panel) {
176
+		$this->assertInstanceOf('WP_Customize_Panel', $panel);
177 177
 	}
178 178
 
179 179
 	/**
180 180
 	 * @see WP_Customize_Panel::print_template()
181 181
 	 */
182 182
 	function test_print_templates_standard() {
183
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
183
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
184 184
 
185
-		$panel = new WP_Customize_Panel( $this->manager, 'baz' );
185
+		$panel = new WP_Customize_Panel($this->manager, 'baz');
186 186
 		ob_start();
187 187
 		$panel->print_template();
188 188
 		$content = ob_get_clean();
189
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-panel-default-content">', $content );
190
-		$this->assertContains( 'accordion-section-title', $content );
191
-		$this->assertContains( 'control-panel-content', $content );
192
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-panel-default">', $content );
193
-		$this->assertContains( 'customize-panel-description', $content );
194
-		$this->assertContains( 'preview-notice', $content );
189
+		$this->assertContains('<script type="text/html" id="tmpl-customize-panel-default-content">', $content);
190
+		$this->assertContains('accordion-section-title', $content);
191
+		$this->assertContains('control-panel-content', $content);
192
+		$this->assertContains('<script type="text/html" id="tmpl-customize-panel-default">', $content);
193
+		$this->assertContains('customize-panel-description', $content);
194
+		$this->assertContains('preview-notice', $content);
195 195
 	}
196 196
 
197 197
 	/**
198 198
 	 * @see WP_Customize_Panel::print_template()
199 199
 	 */
200 200
 	function test_print_templates_custom() {
201
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
201
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
202 202
 
203
-		$panel = new Custom_Panel_Test( $this->manager, 'baz' );
203
+		$panel = new Custom_Panel_Test($this->manager, 'baz');
204 204
 		ob_start();
205 205
 		$panel->print_template();
206 206
 		$content = ob_get_clean();
207
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-panel-titleless-content">', $content );
208
-		$this->assertNotContains( 'accordion-section-title', $content );
207
+		$this->assertContains('<script type="text/html" id="tmpl-customize-panel-titleless-content">', $content);
208
+		$this->assertNotContains('accordion-section-title', $content);
209 209
 
210
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-panel-titleless">', $content );
211
-		$this->assertNotContains( 'preview-notice', $content );
210
+		$this->assertContains('<script type="text/html" id="tmpl-customize-panel-titleless">', $content);
211
+		$this->assertNotContains('preview-notice', $content);
212 212
 	}
213 213
 }
214 214
 
215
-require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-panel.php' );
215
+require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-panel.php');
216 216
 //require_once ABSPATH . WPINC . '/class-wp-customize-panel.php';
217 217
 class Custom_Panel_Test extends WP_Customize_Panel {
218 218
 	public $type = 'titleless';
Please login to merge, or discard this patch.
tests/core/setting.php 1 patch
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 	function setUp() {
21 21
 		parent::setUp();
22
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
22
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
23 23
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
24 24
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
25 25
 		$this->manager = $GLOBALS['wp_customize'];
@@ -28,24 +28,24 @@  discard block
 block discarded – undo
28 28
 
29 29
 	function tearDown() {
30 30
 		$this->manager = null;
31
-		unset( $GLOBALS['wp_customize'] );
31
+		unset($GLOBALS['wp_customize']);
32 32
 		parent::tearDown();
33 33
 	}
34 34
 
35 35
 	function test_constructor_without_args() {
36
-		$setting = new WP_Customize_Setting( $this->manager, 'foo' );
37
-		$this->assertEquals( $this->manager, $setting->manager );
38
-		$this->assertEquals( 'foo', $setting->id );
39
-		$this->assertEquals( 'theme_mod', $setting->type );
40
-		$this->assertEquals( 'edit_theme_options', $setting->capability );
41
-		$this->assertEquals( '', $setting->theme_supports );
42
-		$this->assertEquals( '', $setting->default );
43
-		$this->assertEquals( 'refresh', $setting->transport );
44
-		$this->assertEquals( '', $setting->sanitize_callback );
45
-		$this->assertEquals( '', $setting->sanitize_js_callback );
46
-		$this->assertFalse( has_filter( "customize_sanitize_{$setting->id}" ) );
47
-		$this->assertFalse( has_filter( "customize_sanitize_js_{$setting->id}" ) );
48
-		$this->assertEquals( false, $setting->dirty );
36
+		$setting = new WP_Customize_Setting($this->manager, 'foo');
37
+		$this->assertEquals($this->manager, $setting->manager);
38
+		$this->assertEquals('foo', $setting->id);
39
+		$this->assertEquals('theme_mod', $setting->type);
40
+		$this->assertEquals('edit_theme_options', $setting->capability);
41
+		$this->assertEquals('', $setting->theme_supports);
42
+		$this->assertEquals('', $setting->default);
43
+		$this->assertEquals('refresh', $setting->transport);
44
+		$this->assertEquals('', $setting->sanitize_callback);
45
+		$this->assertEquals('', $setting->sanitize_js_callback);
46
+		$this->assertFalse(has_filter("customize_sanitize_{$setting->id}"));
47
+		$this->assertFalse(has_filter("customize_sanitize_js_{$setting->id}"));
48
+		$this->assertEquals(false, $setting->dirty);
49 49
 	}
50 50
 
51 51
 	function test_constructor_with_args() {
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
 			'theme_supports' => 'widgets',
56 56
 			'default' => 'barbar',
57 57
 			'transport' => 'postMessage',
58
-			'sanitize_callback' => create_function( '$value', 'return $value . ":sanitize_callback";' ),
59
-			'sanitize_js_callback' => create_function( '$value', 'return $value . ":sanitize_js_callback";' ),
58
+			'sanitize_callback' => create_function('$value', 'return $value . ":sanitize_callback";'),
59
+			'sanitize_js_callback' => create_function('$value', 'return $value . ":sanitize_js_callback";'),
60 60
 		);
61
-		$setting = new WP_Customize_Setting( $this->manager, 'bar', $args );
62
-		$this->assertEquals( 'bar', $setting->id );
63
-		foreach ( $args as $key => $value ) {
64
-			$this->assertEquals( $value, $setting->$key );
61
+		$setting = new WP_Customize_Setting($this->manager, 'bar', $args);
62
+		$this->assertEquals('bar', $setting->id);
63
+		foreach ($args as $key => $value) {
64
+			$this->assertEquals($value, $setting->$key);
65 65
 		}
66
-		$this->assertEquals( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );
67
-		$this->assertEquals( 10, has_filter( "customize_sanitize_js_{$setting->id}" ), $args['sanitize_js_callback'] );
66
+		$this->assertEquals(10, has_filter("customize_sanitize_{$setting->id}", $args['sanitize_callback']));
67
+		$this->assertEquals(10, has_filter("customize_sanitize_js_{$setting->id}"), $args['sanitize_js_callback']);
68 68
 	}
69 69
 
70 70
 	public $post_data_overrides = array(
@@ -93,64 +93,64 @@  discard block
 block discarded – undo
93 93
 	 * Run assertions on non-multidimensional standard settings.
94 94
 	 */
95 95
 	function test_preview_standard_types_non_multidimensional() {
96
-		$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
96
+		$_POST['customized'] = wp_slash(wp_json_encode($this->post_data_overrides));
97 97
 
98 98
 		// Try non-multidimensional settings
99
-		foreach ( $this->standard_type_configs as $type => $type_options ) {
99
+		foreach ($this->standard_type_configs as $type => $type_options) {
100 100
 			// Non-multidimensional: See what effect the preview filter has on a non-existent setting (default value should be seen)
101 101
 			$name = "unset_{$type}_without_post_value";
102 102
 			$default = "default_value_{$name}";
103
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
104
-			$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
105
-			$this->assertEquals( $default, $setting->value() );
103
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
104
+			$this->assertEquals($this->undefined, call_user_func($type_options['getter'], $name, $this->undefined));
105
+			$this->assertEquals($default, $setting->value());
106 106
 			$setting->preview();
107
-			$this->assertEquals( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );
108
-			$this->assertEquals( $default, $setting->value() );
107
+			$this->assertEquals($default, call_user_func($type_options['getter'], $name, $this->undefined), sprintf('Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default));
108
+			$this->assertEquals($default, $setting->value());
109 109
 
110 110
 			// Non-multidimensional: See what effect the preview has on an extant setting (default value should not be seen)
111 111
 			$name = "set_{$type}_without_post_value";
112 112
 			$default = "default_value_{$name}";
113 113
 			$initial_value = "initial_value_{$name}";
114
-			call_user_func( $type_options['setter'], $name, $initial_value );
115
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
116
-			$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
117
-			$this->assertEquals( $initial_value, $setting->value() );
114
+			call_user_func($type_options['setter'], $name, $initial_value);
115
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
116
+			$this->assertEquals($initial_value, call_user_func($type_options['getter'], $name));
117
+			$this->assertEquals($initial_value, $setting->value());
118 118
 			$setting->preview();
119
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods)
120
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods)
121
-			$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
122
-			$this->assertEquals( $initial_value, $setting->value() );
119
+			$this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods)
120
+			$this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods)
121
+			$this->assertEquals($initial_value, call_user_func($type_options['getter'], $name));
122
+			$this->assertEquals($initial_value, $setting->value());
123 123
 
124 124
 			// @todo What if we call the setter after preview() is called? If no post_value, should the new set value be stored? If that happens, then the following 3 assertions should be inverted
125 125
 			$overridden_value = "overridden_value_$name";
126
-			call_user_func( $type_options['setter'], $name, $overridden_value );
127
-			$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
128
-			$this->assertEquals( $initial_value, $setting->value() );
129
-			$this->assertNotEquals( $overridden_value, $setting->value() );
126
+			call_user_func($type_options['setter'], $name, $overridden_value);
127
+			$this->assertEquals($initial_value, call_user_func($type_options['getter'], $name));
128
+			$this->assertEquals($initial_value, $setting->value());
129
+			$this->assertNotEquals($overridden_value, $setting->value());
130 130
 
131 131
 			// Non-multidimensional: Test unset setting being overridden by a post value
132 132
 			$name = "unset_{$type}_overridden";
133 133
 			$default = "default_value_{$name}";
134
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
135
-			$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
136
-			$this->assertEquals( $default, $setting->value() );
134
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
135
+			$this->assertEquals($this->undefined, call_user_func($type_options['getter'], $name, $this->undefined));
136
+			$this->assertEquals($default, $setting->value());
137 137
 			$setting->preview(); // activate post_data
138
-			$this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
139
-			$this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
138
+			$this->assertEquals($this->post_data_overrides[$name], call_user_func($type_options['getter'], $name, $this->undefined));
139
+			$this->assertEquals($this->post_data_overrides[$name], $setting->value());
140 140
 
141 141
 			// Non-multidimensional: Test set setting being overridden by a post value
142 142
 			$name = "set_{$type}_overridden";
143 143
 			$default = "default_value_{$name}";
144 144
 			$initial_value = "initial_value_{$name}";
145
-			call_user_func( $type_options['setter'], $name, $initial_value );
146
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
147
-			$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );
148
-			$this->assertEquals( $initial_value, $setting->value() );
145
+			call_user_func($type_options['setter'], $name, $initial_value);
146
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
147
+			$this->assertEquals($initial_value, call_user_func($type_options['getter'], $name, $this->undefined));
148
+			$this->assertEquals($initial_value, $setting->value());
149 149
 			$setting->preview(); // activate post_data
150
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods)
151
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods)
152
-			$this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
153
-			$this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
150
+			$this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods)
151
+			$this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods)
152
+			$this->assertEquals($this->post_data_overrides[$name], call_user_func($type_options['getter'], $name, $this->undefined));
153
+			$this->assertEquals($this->post_data_overrides[$name], $setting->value());
154 154
 		}
155 155
 	}
156 156
 
@@ -158,79 +158,79 @@  discard block
 block discarded – undo
158 158
 	 * Run assertions on multidimensional standard settings.
159 159
 	 */
160 160
 	function test_preview_standard_types_multidimensional() {
161
-		$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
161
+		$_POST['customized'] = wp_slash(wp_json_encode($this->post_data_overrides));
162 162
 
163
-		foreach ( $this->standard_type_configs as $type => $type_options ) {
163
+		foreach ($this->standard_type_configs as $type => $type_options) {
164 164
 			// Multidimensional: See what effect the preview filter has on a non-existent setting (default value should be seen)
165 165
 			$base_name = "unset_{$type}_multi";
166
-			$name = $base_name . '[foo]';
166
+			$name = $base_name.'[foo]';
167 167
 			$default = "default_value_{$name}";
168
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
169
-			$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
170
-			$this->assertEquals( $default, $setting->value() );
168
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
169
+			$this->assertEquals($this->undefined, call_user_func($type_options['getter'], $base_name, $this->undefined));
170
+			$this->assertEquals($default, $setting->value());
171 171
 			$setting->preview();
172
-			$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
173
-			$this->assertArrayHasKey( 'foo', $base_value );
174
-			$this->assertEquals( $default, $base_value['foo'] );
172
+			$base_value = call_user_func($type_options['getter'], $base_name, $this->undefined);
173
+			$this->assertArrayHasKey('foo', $base_value);
174
+			$this->assertEquals($default, $base_value['foo']);
175 175
 
176 176
 			// Multidimensional: See what effect the preview has on an extant setting (default value should not be seen)
177 177
 			$base_name = "set_{$type}_multi";
178
-			$name = $base_name . '[foo]';
178
+			$name = $base_name.'[foo]';
179 179
 			$default = "default_value_{$name}";
180 180
 			$initial_value = "initial_value_{$name}";
181
-			$base_initial_value = array( 'foo' => $initial_value, 'bar' => 'persisted' );
182
-			call_user_func( $type_options['setter'], $base_name, $base_initial_value );
183
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
184
-			$base_value = call_user_func( $type_options['getter'], $base_name, array() );
185
-			$this->assertEquals( $initial_value, $base_value['foo'] );
186
-			$this->assertEquals( $initial_value, $setting->value() );
181
+			$base_initial_value = array('foo' => $initial_value, 'bar' => 'persisted');
182
+			call_user_func($type_options['setter'], $base_name, $base_initial_value);
183
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
184
+			$base_value = call_user_func($type_options['getter'], $base_name, array());
185
+			$this->assertEquals($initial_value, $base_value['foo']);
186
+			$this->assertEquals($initial_value, $setting->value());
187 187
 			$setting->preview();
188
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods)
189
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods)
190
-			$base_value = call_user_func( $type_options['getter'], $base_name, array() );
191
-			$this->assertEquals( $initial_value, $base_value['foo'] );
192
-			$this->assertEquals( $initial_value, $setting->value() );
188
+			$this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods)
189
+			$this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods)
190
+			$base_value = call_user_func($type_options['getter'], $base_name, array());
191
+			$this->assertEquals($initial_value, $base_value['foo']);
192
+			$this->assertEquals($initial_value, $setting->value());
193 193
 
194 194
 			// Multidimensional: Test unset setting being overridden by a post value
195 195
 			$base_name = "unset_{$type}_multi_overridden";
196
-			$name = $base_name . '[foo]';
196
+			$name = $base_name.'[foo]';
197 197
 			$default = "default_value_{$name}";
198
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
199
-			$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
200
-			$this->assertEquals( $default, $setting->value() );
198
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
199
+			$this->assertEquals($this->undefined, call_user_func($type_options['getter'], $base_name, $this->undefined));
200
+			$this->assertEquals($default, $setting->value());
201 201
 			$setting->preview();
202
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods)
203
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods)
204
-			$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
205
-			$this->assertArrayHasKey( 'foo', $base_value );
206
-			$this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
202
+			$this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods)
203
+			$this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods)
204
+			$base_value = call_user_func($type_options['getter'], $base_name, $this->undefined);
205
+			$this->assertArrayHasKey('foo', $base_value);
206
+			$this->assertEquals($this->post_data_overrides[$name], $base_value['foo']);
207 207
 
208 208
 			// Multidimemsional: Test set setting being overridden by a post value
209 209
 			$base_name = "set_{$type}_multi_overridden";
210
-			$name = $base_name . '[foo]';
210
+			$name = $base_name.'[foo]';
211 211
 			$default = "default_value_{$name}";
212 212
 			$initial_value = "initial_value_{$name}";
213
-			$base_initial_value = array( 'foo' => $initial_value, 'bar' => 'persisted' );
214
-			call_user_func( $type_options['setter'], $base_name, $base_initial_value );
215
-			$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
216
-			$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
217
-			$this->arrayHasKey( 'foo', $base_value );
218
-			$this->arrayHasKey( 'bar', $base_value );
219
-			$this->assertEquals( $base_initial_value['foo'], $base_value['foo'] );
220
-
221
-			$getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
222
-			$this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
223
-			$this->assertEquals( $initial_value, $setting->value() );
213
+			$base_initial_value = array('foo' => $initial_value, 'bar' => 'persisted');
214
+			call_user_func($type_options['setter'], $base_name, $base_initial_value);
215
+			$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
216
+			$base_value = call_user_func($type_options['getter'], $base_name, $this->undefined);
217
+			$this->arrayHasKey('foo', $base_value);
218
+			$this->arrayHasKey('bar', $base_value);
219
+			$this->assertEquals($base_initial_value['foo'], $base_value['foo']);
220
+
221
+			$getter = call_user_func($type_options['getter'], $base_name, $this->undefined);
222
+			$this->assertEquals($base_initial_value['bar'], $getter['bar']);
223
+			$this->assertEquals($initial_value, $setting->value());
224 224
 			$setting->preview();
225
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods)
226
-			$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods)
227
-			$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
228
-			$this->assertArrayHasKey( 'foo', $base_value );
229
-			$this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
230
-			$this->arrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
231
-
232
-			$getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
233
-			$this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
225
+			$this->assertEquals(0, did_action("customize_preview_{$setting->id}")); // only applicable for custom types (not options or theme_mods)
226
+			$this->assertEquals(0, did_action("customize_preview_{$setting->type}")); // only applicable for custom types (not options or theme_mods)
227
+			$base_value = call_user_func($type_options['getter'], $base_name, $this->undefined);
228
+			$this->assertArrayHasKey('foo', $base_value);
229
+			$this->assertEquals($this->post_data_overrides[$name], $base_value['foo']);
230
+			$this->arrayHasKey('bar', call_user_func($type_options['getter'], $base_name, $this->undefined));
231
+
232
+			$getter = call_user_func($type_options['getter'], $base_name, $this->undefined);
233
+			$this->assertEquals($base_initial_value['bar'], $getter['bar']);
234 234
 		}
235 235
 	}
236 236
 
@@ -244,33 +244,33 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	protected $custom_type_data_previewed;
246 246
 
247
-	function custom_type_getter( $name, $default = null ) {
248
-		if ( did_action( "customize_preview_{$name}" ) && array_key_exists( $name, $this->custom_type_data_previewed ) ) {
249
-			$value = $this->custom_type_data_previewed[ $name ];
250
-		} else if ( array_key_exists( $name, $this->custom_type_data_saved ) ) {
251
-			$value = $this->custom_type_data_saved[ $name ];
247
+	function custom_type_getter($name, $default = null) {
248
+		if (did_action("customize_preview_{$name}") && array_key_exists($name, $this->custom_type_data_previewed)) {
249
+			$value = $this->custom_type_data_previewed[$name];
250
+		} else if (array_key_exists($name, $this->custom_type_data_saved)) {
251
+			$value = $this->custom_type_data_saved[$name];
252 252
 		} else {
253 253
 			$value = $default;
254 254
 		}
255 255
 		return $value;
256 256
 	}
257 257
 
258
-	function custom_type_setter( $name, $value ) {
259
-		$this->custom_type_data_saved[ $name ] = $value;
258
+	function custom_type_setter($name, $value) {
259
+		$this->custom_type_data_saved[$name] = $value;
260 260
 	}
261 261
 
262
-	function custom_type_value_filter( $default ) {
263
-		$name = preg_replace( '/^customize_value_/', '', current_filter() );
264
-		return $this->custom_type_getter( $name, $default );
262
+	function custom_type_value_filter($default) {
263
+		$name = preg_replace('/^customize_value_/', '', current_filter());
264
+		return $this->custom_type_getter($name, $default);
265 265
 	}
266 266
 
267 267
 	/**
268 268
 	 * @param WP_Customize_Setting $setting
269 269
 	 */
270
-	function custom_type_preview( $setting ) {
271
-		$previewed_value = $setting->post_value( $this->undefined );
272
-		if ( $this->undefined !== $previewed_value ) {
273
-			$this->custom_type_data_previewed[ $setting->id ] = $previewed_value;
270
+	function custom_type_preview($setting) {
271
+		$previewed_value = $setting->post_value($this->undefined);
272
+		if ($this->undefined !== $previewed_value) {
273
+			$this->custom_type_data_previewed[$setting->id] = $previewed_value;
274 274
 		}
275 275
 	}
276 276
 
@@ -280,74 +280,74 @@  discard block
 block discarded – undo
280 280
 			"unset_{$type}_with_post_value" => "unset_{$type}_without_post_value",
281 281
 			"set_{$type}_with_post_value" => "set_{$type}_without_post_value",
282 282
 		);
283
-		$_POST['customized'] = wp_slash( wp_json_encode( $post_data_overrides ) );
283
+		$_POST['customized'] = wp_slash(wp_json_encode($post_data_overrides));
284 284
 
285 285
 		$this->custom_type_data_saved = array();
286 286
 		$this->custom_type_data_previewed = array();
287 287
 
288
-		add_action( "customize_preview_{$type}", array( $this, 'custom_type_preview' ) );
288
+		add_action("customize_preview_{$type}", array($this, 'custom_type_preview'));
289 289
 
290 290
 		// Custom type not existing and no post value override
291 291
 		$name = "unset_{$type}_without_post_value";
292 292
 		$default = "default_value_{$name}";
293
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
293
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
294 294
 		// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need
295
-		add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );
296
-		$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
297
-		$this->assertEquals( $default, $setting->value() );
295
+		add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter'));
296
+		$this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined));
297
+		$this->assertEquals($default, $setting->value());
298 298
 		$setting->preview();
299
-		$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
300
-		$this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) );
301
-		$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default
302
-		$this->assertEquals( $default, $setting->value() ); // should be same as above
299
+		$this->assertEquals(1, did_action("customize_preview_{$setting->id}"));
300
+		$this->assertEquals(1, did_action("customize_preview_{$setting->type}"));
301
+		$this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined)); // Note: for a non-custom type this is $default
302
+		$this->assertEquals($default, $setting->value()); // should be same as above
303 303
 
304 304
 		// Custom type existing and no post value override
305 305
 		$name = "set_{$type}_without_post_value";
306 306
 		$default = "default_value_{$name}";
307 307
 		$initial_value = "initial_value_{$name}";
308
-		$this->custom_type_setter( $name, $initial_value );
309
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
308
+		$this->custom_type_setter($name, $initial_value);
309
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
310 310
 		// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need
311
-		add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );
312
-		$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
313
-		$this->assertEquals( $initial_value, $setting->value() );
311
+		add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter'));
312
+		$this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined));
313
+		$this->assertEquals($initial_value, $setting->value());
314 314
 		$setting->preview();
315
-		$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
316
-		$this->assertEquals( 2, did_action( "customize_preview_{$setting->type}" ) );
317
-		$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // should be same as above
318
-		$this->assertEquals( $initial_value, $setting->value() ); // should be same as above
315
+		$this->assertEquals(1, did_action("customize_preview_{$setting->id}"));
316
+		$this->assertEquals(2, did_action("customize_preview_{$setting->type}"));
317
+		$this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined)); // should be same as above
318
+		$this->assertEquals($initial_value, $setting->value()); // should be same as above
319 319
 
320 320
 		// Custom type not existing and with a post value override
321 321
 		$name = "unset_{$type}_with_post_value";
322 322
 		$default = "default_value_{$name}";
323
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
323
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
324 324
 		// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need
325
-		add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );
326
-		$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
327
-		$this->assertEquals( $default, $setting->value() );
325
+		add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter'));
326
+		$this->assertEquals($this->undefined, $this->custom_type_getter($name, $this->undefined));
327
+		$this->assertEquals($default, $setting->value());
328 328
 		$setting->preview();
329
-		$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
330
-		$this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) );
331
-		$this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
332
-		$this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
329
+		$this->assertEquals(1, did_action("customize_preview_{$setting->id}"));
330
+		$this->assertEquals(3, did_action("customize_preview_{$setting->type}"));
331
+		$this->assertEquals($post_data_overrides[$name], $this->custom_type_getter($name, $this->undefined));
332
+		$this->assertEquals($post_data_overrides[$name], $setting->value());
333 333
 
334 334
 		// Custom type not existing and with a post value override
335 335
 		$name = "set_{$type}_with_post_value";
336 336
 		$default = "default_value_{$name}";
337 337
 		$initial_value = "initial_value_{$name}";
338
-		$this->custom_type_setter( $name, $initial_value );
339
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
338
+		$this->custom_type_setter($name, $initial_value);
339
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
340 340
 		// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need
341
-		add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );
342
-		$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
343
-		$this->assertEquals( $initial_value, $setting->value() );
341
+		add_filter("customize_value_{$name}", array($this, 'custom_type_value_filter'));
342
+		$this->assertEquals($initial_value, $this->custom_type_getter($name, $this->undefined));
343
+		$this->assertEquals($initial_value, $setting->value());
344 344
 		$setting->preview();
345
-		$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
346
-		$this->assertEquals( 4, did_action( "customize_preview_{$setting->type}" ) );
347
-		$this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
348
-		$this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
345
+		$this->assertEquals(1, did_action("customize_preview_{$setting->id}"));
346
+		$this->assertEquals(4, did_action("customize_preview_{$setting->type}"));
347
+		$this->assertEquals($post_data_overrides[$name], $this->custom_type_getter($name, $this->undefined));
348
+		$this->assertEquals($post_data_overrides[$name], $setting->value());
349 349
 
350
-		unset( $this->custom_type_data_previewed, $this->custom_type_data_saved );
350
+		unset($this->custom_type_data_previewed, $this->custom_type_data_saved);
351 351
 	}
352 352
 
353 353
 	/**
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
 		$type = 'option';
360 360
 		$name = 'unset_option_without_post_value';
361 361
 		$default = "default_value_{$name}";
362
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
363
-		$this->assertEquals( $this->undefined, get_option( $name, $this->undefined ) );
364
-		$this->assertEquals( $default, $setting->value() );
362
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type', 'default'));
363
+		$this->assertEquals($this->undefined, get_option($name, $this->undefined));
364
+		$this->assertEquals($default, $setting->value());
365 365
 		$setting->preview();
366
-		$this->assertEquals( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );
367
-		$this->assertEquals( $default, $setting->value() );
366
+		$this->assertEquals($default, get_option($name, $this->undefined), sprintf('Expected get_option(%s) to return setting default: %s.', $name, $default));
367
+		$this->assertEquals($default, $setting->value());
368 368
 	}
369 369
 
370 370
 	/**
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 		$type = 'option';
379 379
 		$name = 'blogname';
380 380
 		$post_value = rand_str();
381
-		$this->manager->set_post_value( $name, $post_value );
382
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
383
-		$this->assertFalse( $setting->is_current_blog_previewed() );
381
+		$this->manager->set_post_value($name, $post_value);
382
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type'));
383
+		$this->assertFalse($setting->is_current_blog_previewed());
384 384
 		$setting->preview();
385
-		$this->assertTrue( $setting->is_current_blog_previewed() );
385
+		$this->assertTrue($setting->is_current_blog_previewed());
386 386
 
387
-		$this->assertEquals( $post_value, $setting->value() );
388
-		$this->assertEquals( $post_value, get_option( $name ) );
387
+		$this->assertEquals($post_value, $setting->value());
388
+		$this->assertEquals($post_value, get_option($name));
389 389
 	}
390 390
 
391 391
 	/**
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
 	 * @group multisite
396 396
 	 */
397 397
 	function test_previewing_with_switch_to_blog() {
398
-		if ( ! is_multisite() ) {
399
-			$this->markTestSkipped( 'Cannot test WP_Customize_Setting::is_current_blog_previewed() with switch_to_blog() if not on multisite.' );
398
+		if ( ! is_multisite()) {
399
+			$this->markTestSkipped('Cannot test WP_Customize_Setting::is_current_blog_previewed() with switch_to_blog() if not on multisite.');
400 400
 		}
401 401
 
402 402
 		$type = 'option';
403 403
 		$name = 'blogdescription';
404 404
 		$post_value = rand_str();
405
-		$this->manager->set_post_value( $name, $post_value );
406
-		$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
407
-		$this->assertFalse( $setting->is_current_blog_previewed() );
405
+		$this->manager->set_post_value($name, $post_value);
406
+		$setting = new WP_Customize_Setting($this->manager, $name, compact('type'));
407
+		$this->assertFalse($setting->is_current_blog_previewed());
408 408
 		$setting->preview();
409
-		$this->assertTrue( $setting->is_current_blog_previewed() );
409
+		$this->assertTrue($setting->is_current_blog_previewed());
410 410
 
411 411
 		$blog_id = $this->factory->blog->create();
412
-		switch_to_blog( $blog_id );
413
-		$this->assertFalse( $setting->is_current_blog_previewed() );
414
-		$this->assertNotEquals( $post_value, $setting->value() );
415
-		$this->assertNotEquals( $post_value, get_option( $name ) );
412
+		switch_to_blog($blog_id);
413
+		$this->assertFalse($setting->is_current_blog_previewed());
414
+		$this->assertNotEquals($post_value, $setting->value());
415
+		$this->assertNotEquals($post_value, get_option($name));
416 416
 		restore_current_blog();
417 417
 	}
418 418
 }
Please login to merge, or discard this patch.
tests/core/nav-menus.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	function setUp() {
23 23
 		parent::setUp();
24
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
24
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
25 25
 		//require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
26
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
26
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
27 27
 		global $wp_customize;
28 28
 		$this->wp_customize = new WP_Customize_Manager();
29 29
 		$wp_customize = $this->wp_customize;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param array $items Menu item types.
45 45
 	 * @return array Menu item types.
46 46
 	 */
47
-	function filter_item_types( $items ) {
47
+	function filter_item_types($items) {
48 48
 		$items[] = array(
49 49
 			'title'  => 'Custom',
50 50
 			'type'   => 'custom_type',
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 	 * @param string $object The object name (e.g. category).
63 63
 	 * @return array Menu items.
64 64
 	 */
65
-	function filter_items( $items, $type, $object ) {
65
+	function filter_items($items, $type, $object) {
66 66
 		$items[] = array(
67 67
 			'id'         => 'custom-1',
68 68
 			'title'      => 'Cool beans',
69 69
 			'type'       => $type,
70 70
 			'type_label' => 'Custom Label',
71 71
 			'object'     => $object,
72
-			'url'        => home_url( '/cool-beans/' ),
72
+			'url'        => home_url('/cool-beans/'),
73 73
 			'classes'    => 'custom-menu-item cool-beans',
74 74
 		);
75 75
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	 * @see WP_Customize_Nav_Menus::__construct()
83 83
 	 */
84 84
 	function test_construct() {
85
-		do_action( 'customize_register', $this->wp_customize );
86
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
87
-		$this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager );
85
+		do_action('customize_register', $this->wp_customize);
86
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
87
+		$this->assertInstanceOf('WP_Customize_Manager', $menus->manager);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
94 94
 	 */
95 95
 	function test_load_available_items_query_returns_wp_error() {
96
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
96
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
97 97
 
98 98
 		// Invalid post type $obj_name.
99
-		$items = $menus->load_available_items_query( 'post_type', 'invalid' );
100
-		$this->assertInstanceOf( 'WP_Error', $items );
101
-		$this->assertEquals( 'nav_menus_invalid_post_type', $items->get_error_code() );
99
+		$items = $menus->load_available_items_query('post_type', 'invalid');
100
+		$this->assertInstanceOf('WP_Error', $items);
101
+		$this->assertEquals('nav_menus_invalid_post_type', $items->get_error_code());
102 102
 
103 103
 		// Invalid taxonomy $obj_name.
104
-		$items = $menus->load_available_items_query( 'taxonomy', 'invalid' );
105
-		$this->assertInstanceOf( 'WP_Error', $items );
106
-		$this->assertEquals( 'invalid_taxonomy', $items->get_error_code() );
104
+		$items = $menus->load_available_items_query('taxonomy', 'invalid');
105
+		$this->assertInstanceOf('WP_Error', $items);
106
+		$this->assertEquals('invalid_taxonomy', $items->get_error_code());
107 107
 	}
108 108
 
109 109
 	/**
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
113 113
 	 */
114 114
 	function test_load_available_items_query_maybe_returns_home() {
115
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
115
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
116 116
 
117 117
 		// Expected menu item array.
118 118
 		$expected = array(
119 119
 			'id'         => 'home',
120
-			'title'      => _x( 'Home', 'nav menu home label' ),
120
+			'title'      => _x('Home', 'nav menu home label'),
121 121
 			'type'       => 'custom',
122
-			'type_label' => __( 'Custom Link' ),
122
+			'type_label' => __('Custom Link'),
123 123
 			'object'     => '',
124 124
 			'url'        => home_url(),
125 125
 		);
126 126
 
127 127
 		// Create pages.
128
-		$this->factory->post->create_many( 15, array( 'post_type' => 'page' ) );
128
+		$this->factory->post->create_many(15, array('post_type' => 'page'));
129 129
 
130 130
 		// Home is included in menu items when page is zero.
131
-		$items = $menus->load_available_items_query( 'post_type', 'page', 0 );
132
-		$this->assertContains( $expected, $items );
131
+		$items = $menus->load_available_items_query('post_type', 'page', 0);
132
+		$this->assertContains($expected, $items);
133 133
 
134 134
 		// Home is not included in menu items when page is larger than zero.
135
-		$items = $menus->load_available_items_query( 'post_type', 'page', 1 );
136
-		$this->assertNotEmpty( $items );
137
-		$this->assertNotContains( $expected, $items );
135
+		$items = $menus->load_available_items_query('post_type', 'page', 1);
136
+		$this->assertNotEmpty($items);
137
+		$this->assertNotContains($expected, $items);
138 138
 	}
139 139
 
140 140
 	/**
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
144 144
 	 */
145 145
 	function test_load_available_items_query_returns_post_item_with_page_number() {
146
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
146
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
147 147
 
148 148
 		// Create page.
149
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) );
149
+		$post_id = $this->factory->post->create(array('post_title' => 'Post Title'));
150 150
 
151 151
 		// Create pages.
152
-		$this->factory->post->create_many( 10 );
152
+		$this->factory->post->create_many(10);
153 153
 
154 154
 		// Expected menu item array.
155 155
 		$expected = array(
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 			'type'       => 'post_type',
159 159
 			'type_label' => 'Post',
160 160
 			'object'     => 'post',
161
-			'object_id'  => intval( $post_id ),
162
-			'url'        => get_permalink( intval( $post_id ) ),
161
+			'object_id'  => intval($post_id),
162
+			'url'        => get_permalink(intval($post_id)),
163 163
 		);
164 164
 
165 165
 		// Offset the query and get the second page of menu items.
166
-		$items = $menus->load_available_items_query( 'post_type', 'post', 1 );
167
-		$this->assertContains( $expected, $items );
166
+		$items = $menus->load_available_items_query('post_type', 'post', 1);
167
+		$this->assertContains($expected, $items);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
174 174
 	 */
175 175
 	function test_load_available_items_query_returns_page_item() {
176
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
176
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
177 177
 
178 178
 		// Create page.
179
-		$page_id = $this->factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
179
+		$page_id = $this->factory->post->create(array('post_title' => 'Page Title', 'post_type' => 'page'));
180 180
 
181 181
 		// Expected menu item array.
182 182
 		$expected = array(
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 			'type'       => 'post_type',
186 186
 			'type_label' => 'Page',
187 187
 			'object'     => 'page',
188
-			'object_id'  => intval( $page_id ),
189
-			'url'        => get_permalink( intval( $page_id ) ),
188
+			'object_id'  => intval($page_id),
189
+			'url'        => get_permalink(intval($page_id)),
190 190
 		);
191 191
 
192
-		$items = $menus->load_available_items_query( 'post_type', 'page', 0 );
193
-		$this->assertContains( $expected, $items );
192
+		$items = $menus->load_available_items_query('post_type', 'page', 0);
193
+		$this->assertContains($expected, $items);
194 194
 	}
195 195
 
196 196
 	/**
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
200 200
 	 */
201 201
 	function test_load_available_items_query_returns_post_item() {
202
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
202
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
203 203
 
204 204
 		// Create post.
205
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) );
205
+		$post_id = $this->factory->post->create(array('post_title' => 'Post Title'));
206 206
 
207 207
 		// Expected menu item array.
208 208
 		$expected = array(
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
 			'type'       => 'post_type',
212 212
 			'type_label' => 'Post',
213 213
 			'object'     => 'post',
214
-			'object_id'  => intval( $post_id ),
215
-			'url'        => get_permalink( intval( $post_id ) ),
214
+			'object_id'  => intval($post_id),
215
+			'url'        => get_permalink(intval($post_id)),
216 216
 		);
217 217
 
218
-		$items = $menus->load_available_items_query( 'post_type', 'post', 0 );
219
-		$this->assertContains( $expected, $items );
218
+		$items = $menus->load_available_items_query('post_type', 'post', 0);
219
+		$this->assertContains($expected, $items);
220 220
 	}
221 221
 
222 222
 	/**
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
226 226
 	 */
227 227
 	function test_load_available_items_query_returns_term_item() {
228
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
228
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
229 229
 
230 230
 		// Create term.
231
-		$term_id = $this->factory->category->create( array( 'name' => 'Term Title' ) );
231
+		$term_id = $this->factory->category->create(array('name' => 'Term Title'));
232 232
 
233 233
 		// Expected menu item array.
234 234
 		$expected = array(
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 			'type'       => 'taxonomy',
238 238
 			'type_label' => 'Category',
239 239
 			'object'     => 'category',
240
-			'object_id'  => intval( $term_id ),
241
-			'url'        => get_term_link( intval( $term_id ), 'category' ),
240
+			'object_id'  => intval($term_id),
241
+			'url'        => get_term_link(intval($term_id), 'category'),
242 242
 		);
243 243
 
244
-		$items = $menus->load_available_items_query( 'taxonomy', 'category', 0 );
245
-		$this->assertContains( $expected, $items );
244
+		$items = $menus->load_available_items_query('taxonomy', 'category', 0);
245
+		$this->assertContains($expected, $items);
246 246
 	}
247 247
 
248 248
 	/**
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @see WP_Customize_Nav_Menus::load_available_items_query()
252 252
 	 */
253 253
 	function test_load_available_items_query_returns_custom_item() {
254
-		add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
255
-		add_filter( 'customize_nav_menu_available_items', array( $this, 'filter_items' ), 10, 4 );
256
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
254
+		add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types'));
255
+		add_filter('customize_nav_menu_available_items', array($this, 'filter_items'), 10, 4);
256
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
257 257
 
258 258
 		// Expected menu item array.
259 259
 		$expected = array(
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
 			'type'       => 'custom_type',
263 263
 			'type_label' => 'Custom Label',
264 264
 			'object'     => 'custom_object',
265
-			'url'        => home_url( '/cool-beans/' ),
265
+			'url'        => home_url('/cool-beans/'),
266 266
 			'classes'    => 'custom-menu-item cool-beans',
267 267
 		);
268 268
 
269
-		$items = $menus->load_available_items_query( 'custom_type', 'custom_object', 0 );
270
-		$this->assertContains( $expected, $items );
269
+		$items = $menus->load_available_items_query('custom_type', 'custom_object', 0);
270
+		$this->assertContains($expected, $items);
271 271
 	}
272 272
 
273 273
 	/**
@@ -276,56 +276,56 @@  discard block
 block discarded – undo
276 276
 	 * @see WP_Customize_Nav_Menus::search_available_items_query()
277 277
 	 */
278 278
 	function test_search_available_items_query() {
279
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
279
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
280 280
 
281 281
 		// Create posts
282 282
 		$post_ids = array();
283
-		$post_ids[] = $this->factory->post->create( array( 'post_title' => 'Search & Test' ) );
284
-		$post_ids[] = $this->factory->post->create( array( 'post_title' => 'Some Other Title' ) );
283
+		$post_ids[] = $this->factory->post->create(array('post_title' => 'Search & Test'));
284
+		$post_ids[] = $this->factory->post->create(array('post_title' => 'Some Other Title'));
285 285
 
286 286
 		// Create terms
287 287
 		$term_ids = array();
288
-		$term_ids[] = $this->factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
289
-		$term_ids[] = $this->factory->category->create( array( 'name' => 'Cats Drool' ) );
288
+		$term_ids[] = $this->factory->category->create(array('name' => 'Dogs Are Cool'));
289
+		$term_ids[] = $this->factory->category->create(array('name' => 'Cats Drool'));
290 290
 
291 291
 		// Test empty results
292 292
 		$expected = array();
293
-		$results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => 'This Does NOT Exist' ) );
294
-		$this->assertEquals( $expected, $results );
293
+		$results = $menus->search_available_items_query(array('pagenum' => 1, 's' => 'This Does NOT Exist'));
294
+		$this->assertEquals($expected, $results);
295 295
 
296 296
 		// Test posts
297
-		foreach ( $post_ids as $post_id ) {
297
+		foreach ($post_ids as $post_id) {
298 298
 			$expected = array(
299
-				'id'         => 'post-' . $post_id,
300
-				'title'      => html_entity_decode( get_the_title( $post_id ) ),
299
+				'id'         => 'post-'.$post_id,
300
+				'title'      => html_entity_decode(get_the_title($post_id)),
301 301
 				'type'       => 'post_type',
302
-				'type_label' => get_post_type_object( 'post' )->labels->singular_name,
302
+				'type_label' => get_post_type_object('post')->labels->singular_name,
303 303
 				'object'     => 'post',
304
-				'object_id'  => intval( $post_id ),
305
-				'url'        => get_permalink( intval( $post_id ) ),
304
+				'object_id'  => intval($post_id),
305
+				'url'        => get_permalink(intval($post_id)),
306 306
 			);
307
-			wp_set_object_terms( $post_id, $term_ids, 'category' );
307
+			wp_set_object_terms($post_id, $term_ids, 'category');
308 308
 			$search = $post_id === $post_ids[0] ? 'test & search' : 'other title';
309
-			$s = sanitize_text_field( wp_unslash( $search ) );
310
-			$results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) );
311
-			$this->assertEquals( $expected, $results[0] );
309
+			$s = sanitize_text_field(wp_unslash($search));
310
+			$results = $menus->search_available_items_query(array('pagenum' => 1, 's' => $s));
311
+			$this->assertEquals($expected, $results[0]);
312 312
 		}
313 313
 
314 314
 		// Test terms
315
-		foreach ( $term_ids as $term_id ) {
316
-			$term = get_term_by( 'id', $term_id, 'category' );
315
+		foreach ($term_ids as $term_id) {
316
+			$term = get_term_by('id', $term_id, 'category');
317 317
 			$expected = array(
318
-				'id'         => 'term-' . $term_id,
318
+				'id'         => 'term-'.$term_id,
319 319
 				'title'      => $term->name,
320 320
 				'type'       => 'taxonomy',
321
-				'type_label' => get_taxonomy( 'category' )->labels->singular_name,
321
+				'type_label' => get_taxonomy('category')->labels->singular_name,
322 322
 				'object'     => 'category',
323
-				'object_id'  => intval( $term_id ),
324
-				'url'        => get_term_link( intval( $term_id ), 'category' ),
323
+				'object_id'  => intval($term_id),
324
+				'url'        => get_term_link(intval($term_id), 'category'),
325 325
 			);
326
-			$s = sanitize_text_field( wp_unslash( $term->name ) );
327
-			$results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) );
328
-			$this->assertEquals( $expected, $results[0] );
326
+			$s = sanitize_text_field(wp_unslash($term->name));
327
+			$results = $menus->search_available_items_query(array('pagenum' => 1, 's' => $s));
328
+			$this->assertEquals($expected, $results[0]);
329 329
 		}
330 330
 	}
331 331
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 	 * @see WP_Customize_Nav_Menus::enqueue_scripts()
336 336
 	 */
337 337
 	function test_enqueue_scripts() {
338
-		do_action( 'customize_register', $this->wp_customize );
339
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
338
+		do_action('customize_register', $this->wp_customize);
339
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
340 340
 		$menus->enqueue_scripts();
341
-		$this->assertTrue( wp_script_is( 'customize-nav-menus' ) );
341
+		$this->assertTrue(wp_script_is('customize-nav-menus'));
342 342
 	}
343 343
 
344 344
 	/**
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 	 * @see WP_Customize_Nav_Menus::filter_dynamic_setting_args()
348 348
 	 */
349 349
 	function test_filter_dynamic_setting_args() {
350
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
350
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
351 351
 
352
-		$expected = array( 'type' => 'nav_menu_item' );
353
-		$results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' );
354
-		$this->assertEquals( $expected, $results );
352
+		$expected = array('type' => 'nav_menu_item');
353
+		$results = $menus->filter_dynamic_setting_args($this->wp_customize, 'nav_menu_item[123]');
354
+		$this->assertEquals($expected, $results);
355 355
 
356
-		$expected = array( 'type' => 'nav_menu' );
357
-		$results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' );
358
-		$this->assertEquals( $expected, $results );
356
+		$expected = array('type' => 'nav_menu');
357
+		$results = $menus->filter_dynamic_setting_args($this->wp_customize, 'nav_menu[123]');
358
+		$this->assertEquals($expected, $results);
359 359
 	}
360 360
 
361 361
 	/**
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 	 * @see WP_Customize_Nav_Menus::filter_dynamic_setting_class()
365 365
 	 */
366 366
 	function test_filter_dynamic_setting_class() {
367
-		do_action( 'customize_register', $this->wp_customize );
368
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
367
+		do_action('customize_register', $this->wp_customize);
368
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
369 369
 
370 370
 		$expected = 'WP_Customize_Nav_Menu_Item_Setting';
371
-		$results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) );
372
-		$this->assertEquals( $expected, $results );
371
+		$results = $menus->filter_dynamic_setting_class('WP_Customize_Setting', 'nav_menu_item[123]', array('type' => 'nav_menu_item'));
372
+		$this->assertEquals($expected, $results);
373 373
 
374 374
 		$expected = 'WP_Customize_Nav_Menu_Setting';
375
-		$results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) );
376
-		$this->assertEquals( $expected, $results );
375
+		$results = $menus->filter_dynamic_setting_class('WP_Customize_Setting', 'nav_menu[123]', array('type' => 'nav_menu'));
376
+		$this->assertEquals($expected, $results);
377 377
 	}
378 378
 
379 379
 	/**
@@ -382,20 +382,20 @@  discard block
 block discarded – undo
382 382
 	 * @see WP_Customize_Nav_Menus::customize_register()
383 383
 	 */
384 384
 	function test_customize_register() {
385
-		do_action( 'customize_register', $this->wp_customize );
386
-		$menu_id = wp_create_nav_menu( 'Primary' );
387
-		$post_id = $this->factory->post->create( array( 'post_title' => 'Hello World' ) );
388
-		$item_id = wp_update_nav_menu_item( $menu_id, 0, array(
385
+		do_action('customize_register', $this->wp_customize);
386
+		$menu_id = wp_create_nav_menu('Primary');
387
+		$post_id = $this->factory->post->create(array('post_title' => 'Hello World'));
388
+		$item_id = wp_update_nav_menu_item($menu_id, 0, array(
389 389
 			'menu-item-type'      => 'post_type',
390 390
 			'menu-item-object'    => 'post',
391 391
 			'menu-item-object-id' => $post_id,
392 392
 			'menu-item-title'     => 'Hello World',
393 393
 			'menu-item-status'    => 'publish',
394
-		) );
395
-		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, "nav_menu_item[$item_id]" );
396
-		do_action( 'customize_register', $this->wp_customize );
397
-		$this->assertEquals( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title );
398
-		$this->assertEquals( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label );
394
+		));
395
+		$setting = new WP_Customize_Nav_Menu_Item_Setting($this->wp_customize, "nav_menu_item[$item_id]");
396
+		do_action('customize_register', $this->wp_customize);
397
+		$this->assertEquals('Primary', $this->wp_customize->get_section("nav_menu[$menu_id]")->title);
398
+		$this->assertEquals('Hello World', $this->wp_customize->get_control("nav_menu_item[$item_id]")->label);
399 399
 	}
400 400
 
401 401
 	/**
@@ -405,16 +405,16 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	function test_intval_base10() {
407 407
 
408
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
408
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
409 409
 
410
-		$this->assertEquals( 2, $menus->intval_base10( 2 ) );
411
-		$this->assertEquals( 4, $menus->intval_base10( 4.1 ) );
412
-		$this->assertEquals( 4, $menus->intval_base10( '4' ) );
413
-		$this->assertEquals( 4, $menus->intval_base10( '04' ) );
414
-		$this->assertEquals( 42, $menus->intval_base10( +42 ) );
410
+		$this->assertEquals(2, $menus->intval_base10(2));
411
+		$this->assertEquals(4, $menus->intval_base10(4.1));
412
+		$this->assertEquals(4, $menus->intval_base10('4'));
413
+		$this->assertEquals(4, $menus->intval_base10('04'));
414
+		$this->assertEquals(42, $menus->intval_base10( +42 ));
415 415
 		$this->assertEquals( -42, $menus->intval_base10( -42 ) );
416
-		$this->assertEquals( 26, $menus->intval_base10( 0x1A ) );
417
-		$this->assertEquals( 0, $menus->intval_base10( array() ) );
416
+		$this->assertEquals(26, $menus->intval_base10(0x1A));
417
+		$this->assertEquals(0, $menus->intval_base10(array()));
418 418
 	}
419 419
 
420 420
 	/**
@@ -424,31 +424,31 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	function test_available_item_types() {
426 426
 
427
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
427
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
428 428
 
429 429
 		$expected = array(
430
-			array( 'title' => 'Post', 'type' => 'post_type', 'object' => 'post' ),
431
-			array( 'title' => 'Page', 'type' => 'post_type', 'object' => 'page' ),
432
-			array( 'title' => 'Category', 'type' => 'taxonomy', 'object' => 'category' ),
433
-			array( 'title' => 'Tag', 'type' => 'taxonomy', 'object' => 'post_tag' ),
430
+			array('title' => 'Post', 'type' => 'post_type', 'object' => 'post'),
431
+			array('title' => 'Page', 'type' => 'post_type', 'object' => 'page'),
432
+			array('title' => 'Category', 'type' => 'taxonomy', 'object' => 'category'),
433
+			array('title' => 'Tag', 'type' => 'taxonomy', 'object' => 'post_tag'),
434 434
 		);
435 435
 
436
-		if ( current_theme_supports( 'post-formats' ) ) {
437
-			$expected[] = array( 'title' => 'Format', 'type' => 'taxonomy', 'object' => 'post_format' );
436
+		if (current_theme_supports('post-formats')) {
437
+			$expected[] = array('title' => 'Format', 'type' => 'taxonomy', 'object' => 'post_format');
438 438
 		}
439 439
 
440
-		$this->assertEquals( $expected, $menus->available_item_types() );
440
+		$this->assertEquals($expected, $menus->available_item_types());
441 441
 
442
-		register_taxonomy( 'wptests_tax', array( 'post' ), array( 'labels' => array( 'name' => 'Foo' ) ) );
443
-		$expected[] = array( 'title' => 'Foo', 'type' => 'taxonomy', 'object' => 'wptests_tax' );
442
+		register_taxonomy('wptests_tax', array('post'), array('labels' => array('name' => 'Foo')));
443
+		$expected[] = array('title' => 'Foo', 'type' => 'taxonomy', 'object' => 'wptests_tax');
444 444
 
445
-		$this->assertEquals( $expected, $menus->available_item_types() );
445
+		$this->assertEquals($expected, $menus->available_item_types());
446 446
 
447
-		$expected[] = array( 'title' => 'Custom', 'type' => 'custom_type', 'object' => 'custom_object' );
447
+		$expected[] = array('title' => 'Custom', 'type' => 'custom_type', 'object' => 'custom_object');
448 448
 
449
-		add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
450
-		$this->assertEquals( $expected, $menus->available_item_types() );
451
-		remove_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
449
+		add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types'));
450
+		$this->assertEquals($expected, $menus->available_item_types());
451
+		remove_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types'));
452 452
 
453 453
 	}
454 454
 
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
 	 * @see WP_Customize_Nav_Menus::print_templates()
459 459
 	 */
460 460
 	function test_print_templates() {
461
-		do_action( 'customize_register', $this->wp_customize );
462
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
461
+		do_action('customize_register', $this->wp_customize);
462
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
463 463
 
464 464
 		ob_start();
465 465
 		$menus->print_templates();
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
 
468 468
 		$expected = sprintf(
469 469
 			'<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>',
470
-			esc_html( 'Move up' ),
471
-			esc_html( 'Move down' ),
472
-			esc_html( 'Move one level up' ),
473
-			esc_html( 'Move one level down' )
470
+			esc_html('Move up'),
471
+			esc_html('Move down'),
472
+			esc_html('Move one level up'),
473
+			esc_html('Move one level down')
474 474
 		);
475 475
 
476
-		$this->assertContains( $expected, $template );
476
+		$this->assertContains($expected, $template);
477 477
 	}
478 478
 
479 479
 	/**
@@ -482,42 +482,42 @@  discard block
 block discarded – undo
482 482
 	 * @see WP_Customize_Nav_Menus::available_items_template()
483 483
 	 */
484 484
 	function test_available_items_template() {
485
-		add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
486
-		do_action( 'customize_register', $this->wp_customize );
487
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
485
+		add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types'));
486
+		do_action('customize_register', $this->wp_customize);
487
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
488 488
 
489 489
 		ob_start();
490 490
 		$menus->available_items_template();
491 491
 		$template = ob_get_clean();
492 492
 
493
-		$expected = sprintf( 'Customizing &#9656; %s', esc_html( $this->wp_customize->get_panel( 'nav_menus' )->title ) );
493
+		$expected = sprintf('Customizing &#9656; %s', esc_html($this->wp_customize->get_panel('nav_menus')->title));
494 494
 
495
-		$this->assertContains( $expected, $template );
495
+		$this->assertContains($expected, $template);
496 496
 
497
-		$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
498
-		if ( $post_types ) {
499
-			foreach ( $post_types as $type ) {
500
-				$this->assertContains( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
501
-				$this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->singular_name ) . '#', $template );
502
-				$this->assertContains( 'data-type="post_type"', $template );
503
-				$this->assertContains( 'data-object="' . esc_attr( $type->name ) . '"', $template );
497
+		$post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
498
+		if ($post_types) {
499
+			foreach ($post_types as $type) {
500
+				$this->assertContains('available-menu-items-post_type-'.esc_attr($type->name), $template);
501
+				$this->assertRegExp('#<h4 class="accordion-section-title".*>\s*'.esc_html($type->labels->singular_name).'#', $template);
502
+				$this->assertContains('data-type="post_type"', $template);
503
+				$this->assertContains('data-object="'.esc_attr($type->name).'"', $template);
504 504
 			}
505 505
 		}
506 506
 
507
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
508
-		if ( $taxonomies ) {
509
-			foreach ( $taxonomies as $tax ) {
510
-				$this->assertContains( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
511
-				$this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->singular_name ) . '#', $template );
512
-				$this->assertContains( 'data-type="taxonomy"', $template );
513
-				$this->assertContains( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
507
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
508
+		if ($taxonomies) {
509
+			foreach ($taxonomies as $tax) {
510
+				$this->assertContains('available-menu-items-taxonomy-'.esc_attr($tax->name), $template);
511
+				$this->assertRegExp('#<h4 class="accordion-section-title".*>\s*'.esc_html($tax->labels->singular_name).'#', $template);
512
+				$this->assertContains('data-type="taxonomy"', $template);
513
+				$this->assertContains('data-object="'.esc_attr($tax->name).'"', $template);
514 514
 			}
515 515
 		}
516 516
 
517
-		$this->assertContains( 'available-menu-items-custom_type', $template );
518
-		$this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );
519
-		$this->assertContains( 'data-type="custom_type"', $template );
520
-		$this->assertContains( 'data-object="custom_object"', $template );
517
+		$this->assertContains('available-menu-items-custom_type', $template);
518
+		$this->assertRegExp('#<h4 class="accordion-section-title".*>\s*Custom#', $template);
519
+		$this->assertContains('data-type="custom_type"', $template);
520
+		$this->assertContains('data-object="custom_object"', $template);
521 521
 	}
522 522
 
523 523
 	/**
@@ -526,16 +526,16 @@  discard block
 block discarded – undo
526 526
 	 * @see WP_Customize_Nav_Menus::customize_preview_init()
527 527
 	 */
528 528
 	function test_customize_preview_init() {
529
-		do_action( 'customize_register', $this->wp_customize );
530
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
529
+		do_action('customize_register', $this->wp_customize);
530
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
531 531
 
532 532
 		$menus->customize_preview_init();
533
-		$this->assertEquals( 10, has_action( 'template_redirect', array( $menus, 'render_menu' ) ) );
534
-		$this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) );
533
+		$this->assertEquals(10, has_action('template_redirect', array($menus, 'render_menu')));
534
+		$this->assertEquals(10, has_action('wp_enqueue_scripts', array($menus, 'customize_preview_enqueue_deps')));
535 535
 
536
-		if ( ! isset( $_REQUEST[ WP_Customize_Nav_Menus::RENDER_QUERY_VAR ] ) ) {
537
-			$this->assertEquals( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) );
538
-			$this->assertEquals( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) );
536
+		if ( ! isset($_REQUEST[WP_Customize_Nav_Menus::RENDER_QUERY_VAR])) {
537
+			$this->assertEquals(1000, has_filter('wp_nav_menu_args', array($menus, 'filter_wp_nav_menu_args')));
538
+			$this->assertEquals(10, has_filter('wp_nav_menu', array($menus, 'filter_wp_nav_menu')));
539 539
 		}
540 540
 	}
541 541
 
@@ -545,16 +545,16 @@  discard block
 block discarded – undo
545 545
 	 * @see WP_Customize_Nav_Menus::filter_wp_nav_menu_args()
546 546
 	 */
547 547
 	function test_filter_wp_nav_menu_args() {
548
-		do_action( 'customize_register', $this->wp_customize );
549
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
548
+		do_action('customize_register', $this->wp_customize);
549
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
550 550
 
551
-		$results = $menus->filter_wp_nav_menu_args( array(
551
+		$results = $menus->filter_wp_nav_menu_args(array(
552 552
 			'echo'            => true,
553 553
 			'fallback_cb'     => 'wp_page_menu',
554 554
 			'walker'          => '',
555
-			'menu'            => wp_create_nav_menu( 'Foo' ),
556
-		) );
557
-		$this->assertEquals( 1, $results['can_partial_refresh'] );
555
+			'menu'            => wp_create_nav_menu('Foo'),
556
+		));
557
+		$this->assertEquals(1, $results['can_partial_refresh']);
558 558
 
559 559
 		$expected = array(
560 560
 			'echo',
@@ -563,20 +563,20 @@  discard block
 block discarded – undo
563 563
 			'instance_number',
564 564
 			'walker',
565 565
 		);
566
-		$results = $menus->filter_wp_nav_menu_args( array(
566
+		$results = $menus->filter_wp_nav_menu_args(array(
567 567
 			'echo'            => false,
568 568
 			'fallback_cb'     => 'wp_page_menu',
569 569
 			'walker'          => new Walker_Nav_Menu(),
570
-		) );
571
-		$this->assertEqualSets( $expected, array_keys( $results ) );
572
-		$this->assertEquals( 'wp_page_menu', $results['fallback_cb'] );
573
-		$this->assertEquals( 0, $results['can_partial_refresh'] );
574
-
575
-		$this->assertNotEmpty( $menus->preview_nav_menu_instance_args[ $results['instance_number'] ] );
576
-		$preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[ $results['instance_number'] ];
577
-		$this->assertEquals( '', $preview_nav_menu_instance_args['fallback_cb'] );
578
-		$this->assertEquals( '', $preview_nav_menu_instance_args['walker'] );
579
-		$this->assertNotEmpty( $preview_nav_menu_instance_args['args_hash'] );
570
+		));
571
+		$this->assertEqualSets($expected, array_keys($results));
572
+		$this->assertEquals('wp_page_menu', $results['fallback_cb']);
573
+		$this->assertEquals(0, $results['can_partial_refresh']);
574
+
575
+		$this->assertNotEmpty($menus->preview_nav_menu_instance_args[$results['instance_number']]);
576
+		$preview_nav_menu_instance_args = $menus->preview_nav_menu_instance_args[$results['instance_number']];
577
+		$this->assertEquals('', $preview_nav_menu_instance_args['fallback_cb']);
578
+		$this->assertEquals('', $preview_nav_menu_instance_args['walker']);
579
+		$this->assertNotEmpty($preview_nav_menu_instance_args['args_hash']);
580 580
 	}
581 581
 
582 582
 	/**
@@ -585,27 +585,27 @@  discard block
 block discarded – undo
585 585
 	 * @see WP_Customize_Nav_Menus::filter_wp_nav_menu()
586 586
 	 */
587 587
 	function test_filter_wp_nav_menu() {
588
-		do_action( 'customize_register', $this->wp_customize );
589
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
588
+		do_action('customize_register', $this->wp_customize);
589
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
590 590
 
591
-		$args = $menus->filter_wp_nav_menu_args( array(
591
+		$args = $menus->filter_wp_nav_menu_args(array(
592 592
 			'echo'        => true,
593
-			'menu'        => wp_create_nav_menu( 'Foo' ),
593
+			'menu'        => wp_create_nav_menu('Foo'),
594 594
 			'fallback_cb' => 'wp_page_menu',
595 595
 			'walker'      => '',
596
-		) );
596
+		));
597 597
 
598 598
 		ob_start();
599
-		wp_nav_menu( $args );
599
+		wp_nav_menu($args);
600 600
 		$nav_menu_content = ob_get_clean();
601 601
 
602
-		$object_args = json_decode( json_encode( $args ), false );
603
-		$result = $menus->filter_wp_nav_menu( $nav_menu_content, $object_args );
602
+		$object_args = json_decode(json_encode($args), false);
603
+		$result = $menus->filter_wp_nav_menu($nav_menu_content, $object_args);
604 604
 		$expected = sprintf(
605 605
 			'<div class="partial-refreshable-nav-menu partial-refreshable-nav-menu-%1$d menu">',
606 606
 			$args['instance_number']
607 607
 		);
608
-		$this->assertStringStartsWith( $expected, $result );
608
+		$this->assertStringStartsWith($expected, $result);
609 609
 	}
610 610
 
611 611
 	/**
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 	 * @see WP_Customize_Nav_Menus::customize_preview_enqueue_deps()
615 615
 	 */
616 616
 	function test_customize_preview_enqueue_deps() {
617
-		do_action( 'customize_register', $this->wp_customize );
618
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
617
+		do_action('customize_register', $this->wp_customize);
618
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
619 619
 
620 620
 		$menus->customize_preview_enqueue_deps();
621 621
 
622
-		$this->assertTrue( wp_script_is( 'customize-preview-nav-menus' ) );
623
-		$this->assertEquals( 10, has_action( 'wp_print_footer_scripts', array( $menus, 'export_preview_data' ) ) );
622
+		$this->assertTrue(wp_script_is('customize-preview-nav-menus'));
623
+		$this->assertEquals(10, has_action('wp_print_footer_scripts', array($menus, 'export_preview_data')));
624 624
 	}
625 625
 
626 626
 	/**
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @see WP_Customize_Nav_Menus::export_preview_data()
630 630
 	 */
631 631
 	function test_export_preview_data() {
632
-		do_action( 'customize_register', $this->wp_customize );
633
-		$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
632
+		do_action('customize_register', $this->wp_customize);
633
+		$menus = new WP_Customize_Nav_Menus($this->wp_customize);
634 634
 
635 635
 		$request_uri = $_SERVER['REQUEST_URI'];
636 636
 
@@ -641,15 +641,15 @@  discard block
 block discarded – undo
641 641
 
642 642
 		$_SERVER['REQUEST_URI'] = $request_uri;
643 643
 
644
-		$this->assertContains( '_wpCustomizePreviewNavMenusExports', $data );
645
-		$this->assertContains( 'renderQueryVar', $data );
646
-		$this->assertContains( 'renderNonceValue', $data );
647
-		$this->assertContains( 'renderNoncePostKey', $data );
648
-		$this->assertContains( 'requestUri', $data );
649
-		$this->assertContains( 'theme', $data );
650
-		$this->assertContains( 'previewCustomizeNonce', $data );
651
-		$this->assertContains( 'navMenuInstanceArgs', $data );
652
-		$this->assertContains( 'requestUri', $data );
644
+		$this->assertContains('_wpCustomizePreviewNavMenusExports', $data);
645
+		$this->assertContains('renderQueryVar', $data);
646
+		$this->assertContains('renderNonceValue', $data);
647
+		$this->assertContains('renderNoncePostKey', $data);
648
+		$this->assertContains('requestUri', $data);
649
+		$this->assertContains('theme', $data);
650
+		$this->assertContains('previewCustomizeNonce', $data);
651
+		$this->assertContains('navMenuInstanceArgs', $data);
652
+		$this->assertContains('requestUri', $data);
653 653
 
654 654
 	}
655 655
 
Please login to merge, or discard this patch.
tests/core/manager.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 	function setUp() {
11 11
 		parent::setUp();
12
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
12
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
13 13
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
14 14
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
15 15
 		$this->manager = $GLOBALS['wp_customize'];
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 	function tearDown() {
20 20
 		$this->manager = null;
21
-		unset( $GLOBALS['wp_customize'] );
21
+		unset($GLOBALS['wp_customize']);
22 22
 		parent::tearDown();
23 23
 	}
24 24
 
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
 	 * @group ajax
39 39
 	 */
40 40
 	function test_doing_ajax() {
41
-		if ( ! defined( 'DOING_AJAX' ) ) {
42
-			define( 'DOING_AJAX', true );
41
+		if ( ! defined('DOING_AJAX')) {
42
+			define('DOING_AJAX', true);
43 43
 		}
44 44
 
45 45
 		$manager = $this->instantiate();
46
-		$this->assertTrue( $manager->doing_ajax() );
46
+		$this->assertTrue($manager->doing_ajax());
47 47
 
48 48
 		$_REQUEST['action'] = 'customize_save';
49
-		$this->assertTrue( $manager->doing_ajax( 'customize_save' ) );
50
-		$this->assertFalse( $manager->doing_ajax( 'update-widget' ) );
49
+		$this->assertTrue($manager->doing_ajax('customize_save'));
50
+		$this->assertFalse($manager->doing_ajax('update-widget'));
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * Test ! WP_Customize_Manager::doing_ajax().
55 55
 	 */
56 56
 	function test_not_doing_ajax() {
57
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
58
-			$this->markTestSkipped( 'Cannot test when DOING_AJAX' );
57
+		if (defined('DOING_AJAX') && DOING_AJAX) {
58
+			$this->markTestSkipped('Cannot test when DOING_AJAX');
59 59
 		}
60 60
 
61 61
 		$manager = $this->instantiate();
62
-		$this->assertFalse( $manager->doing_ajax() );
62
+		$this->assertFalse($manager->doing_ajax());
63 63
 	}
64 64
 
65 65
 	/**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 			'foo' => 'bar',
75 75
 			'baz[quux]' => 123,
76 76
 		);
77
-		$_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
77
+		$_POST['customized'] = wp_slash(wp_json_encode($customized));
78 78
 		$post_values = $manager->unsanitized_post_values();
79
-		$this->assertEquals( $customized, $post_values );
79
+		$this->assertEquals($customized, $post_values);
80 80
 	}
81 81
 
82 82
 	/**
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 		$posted_settings = array(
89 89
 			'foo' => 'OOF',
90 90
 		);
91
-		$_POST['customized'] = wp_slash( wp_json_encode( $posted_settings ) );
91
+		$_POST['customized'] = wp_slash(wp_json_encode($posted_settings));
92 92
 
93 93
 		$manager = $this->instantiate();
94 94
 
95
-		$manager->add_setting( 'foo', array( 'default' => 'foo_default' ) );
96
-		$foo_setting = $manager->get_setting( 'foo' );
97
-		$this->assertEquals( 'foo_default', $manager->get_setting( 'foo' )->value(), 'Expected non-previewed setting to return default when value() method called.' );
98
-		$this->assertEquals( $posted_settings['foo'], $manager->post_value( $foo_setting, 'post_value_foo_default' ), 'Expected post_value($foo_setting) to return value supplied in $_POST[customized][foo]' );
95
+		$manager->add_setting('foo', array('default' => 'foo_default'));
96
+		$foo_setting = $manager->get_setting('foo');
97
+		$this->assertEquals('foo_default', $manager->get_setting('foo')->value(), 'Expected non-previewed setting to return default when value() method called.');
98
+		$this->assertEquals($posted_settings['foo'], $manager->post_value($foo_setting, 'post_value_foo_default'), 'Expected post_value($foo_setting) to return value supplied in $_POST[customized][foo]');
99 99
 
100
-		$manager->add_setting( 'bar', array( 'default' => 'bar_default' ) );
101
-		$bar_setting = $manager->get_setting( 'bar' );
102
-		$this->assertEquals( 'post_value_bar_default', $manager->post_value( $bar_setting, 'post_value_bar_default' ), 'Expected post_value($bar_setting, $default) to return $default since no value supplied in $_POST[customized][bar]' );
100
+		$manager->add_setting('bar', array('default' => 'bar_default'));
101
+		$bar_setting = $manager->get_setting('bar');
102
+		$this->assertEquals('post_value_bar_default', $manager->post_value($bar_setting, 'post_value_bar_default'), 'Expected post_value($bar_setting, $default) to return $default since no value supplied in $_POST[customized][bar]');
103 103
 	}
104 104
 
105 105
 	/**
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	function test_add_dynamic_settings() {
111 111
 		$manager = $this->instantiate();
112
-		$setting_ids = array( 'foo', 'bar' );
113
-		$manager->add_setting( 'foo', array( 'default' => 'foo_default' ) );
114
-		$this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected there to not be a bar setting up front.' );
115
-		$manager->add_dynamic_settings( $setting_ids );
116
-		$this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected the bar setting to remain absent since filters not added.' );
112
+		$setting_ids = array('foo', 'bar');
113
+		$manager->add_setting('foo', array('default' => 'foo_default'));
114
+		$this->assertEmpty($manager->get_setting('bar'), 'Expected there to not be a bar setting up front.');
115
+		$manager->add_dynamic_settings($setting_ids);
116
+		$this->assertEmpty($manager->get_setting('bar'), 'Expected the bar setting to remain absent since filters not added.');
117 117
 
118 118
 		$this->action_customize_register_for_dynamic_settings();
119
-		$manager->add_dynamic_settings( $setting_ids );
120
-		$this->assertNotEmpty( $manager->get_setting( 'bar' ), 'Expected bar setting to be created since filters were added.' );
121
-		$this->assertEquals( 'foo_default', $manager->get_setting( 'foo' )->default, 'Expected static foo setting to not get overridden by dynamic setting.' );
122
-		$this->assertEquals( 'dynamic_bar_default', $manager->get_setting( 'bar' )->default, 'Expected dynamic setting bar to have default providd by filter.' );
119
+		$manager->add_dynamic_settings($setting_ids);
120
+		$this->assertNotEmpty($manager->get_setting('bar'), 'Expected bar setting to be created since filters were added.');
121
+		$this->assertEquals('foo_default', $manager->get_setting('foo')->default, 'Expected static foo setting to not get overridden by dynamic setting.');
122
+		$this->assertEquals('dynamic_bar_default', $manager->get_setting('bar')->default, 'Expected dynamic setting bar to have default providd by filter.');
123 123
 	}
124 124
 
125 125
 	/**
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
 			'foo' => 'OOF',
135 135
 			'bar' => 'RAB',
136 136
 		);
137
-		$_POST['customized'] = wp_slash( wp_json_encode( $posted_settings ) );
137
+		$_POST['customized'] = wp_slash(wp_json_encode($posted_settings));
138 138
 
139
-		add_action( 'customize_register', array( $this, 'action_customize_register_for_dynamic_settings' ) );
139
+		add_action('customize_register', array($this, 'action_customize_register_for_dynamic_settings'));
140 140
 
141 141
 		$manager = $this->instantiate();
142
-		$manager->add_setting( 'foo', array( 'default' => 'foo_default' ) );
142
+		$manager->add_setting('foo', array('default' => 'foo_default'));
143 143
 
144
-		$this->assertEmpty( $manager->get_setting( 'bar' ), 'Expected dynamic setting "bar" to not be registered.' );
145
-		do_action( 'customize_register', $manager );
146
-		$this->assertNotEmpty( $manager->get_setting( 'bar' ), 'Expected dynamic setting "bar" to be automatically registered after customize_register action.' );
147
-		$this->assertEmpty( $manager->get_setting( 'baz' ), 'Expected unrecognized dynamic setting "baz" to remain unregistered.' );
144
+		$this->assertEmpty($manager->get_setting('bar'), 'Expected dynamic setting "bar" to not be registered.');
145
+		do_action('customize_register', $manager);
146
+		$this->assertNotEmpty($manager->get_setting('bar'), 'Expected dynamic setting "bar" to be automatically registered after customize_register action.');
147
+		$this->assertEmpty($manager->get_setting('baz'), 'Expected unrecognized dynamic setting "baz" to remain unregistered.');
148 148
 	}
149 149
 
150 150
 	/**
151 151
 	 * In lieu of closures, callback for customize_register action added in test_register_dynamic_settings().
152 152
 	 */
153 153
 	function action_customize_register_for_dynamic_settings() {
154
-		add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings' ), 10, 2 );
155
-		add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings' ), 10, 3 );
154
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings'), 10, 2);
155
+		add_filter('customize_dynamic_setting_class', array($this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings'), 10, 3);
156 156
 	}
157 157
 
158 158
 	/**
159 159
 	 * In lieu of closures, callback for customize_dynamic_setting_args filter added for test_register_dynamic_settings().
160 160
 	 */
161
-	function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) {
162
-		$this->assertEquals( false, $setting_args, 'Expected $setting_args to be false by default.' );
163
-		$this->assertInternalType( 'string', $setting_id );
164
-		if ( in_array( $setting_id, array( 'foo', 'bar' ) ) ) {
165
-			$setting_args = array( 'default' => "dynamic_{$setting_id}_default" );
161
+	function filter_customize_dynamic_setting_args_for_test_dynamic_settings($setting_args, $setting_id) {
162
+		$this->assertEquals(false, $setting_args, 'Expected $setting_args to be false by default.');
163
+		$this->assertInternalType('string', $setting_id);
164
+		if (in_array($setting_id, array('foo', 'bar'))) {
165
+			$setting_args = array('default' => "dynamic_{$setting_id}_default");
166 166
 		}
167 167
 		return $setting_args;
168 168
 	}
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 	/**
171 171
 	 * In lieu of closures, callback for customize_dynamic_setting_class filter added for test_register_dynamic_settings().
172 172
 	 */
173
-	function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) {
174
-		$this->assertEquals( 'WP_Customize_Setting', $setting_class );
175
-		$this->assertInternalType( 'string', $setting_id );
176
-		$this->assertInternalType( 'array', $setting_args );
173
+	function filter_customize_dynamic_setting_class_for_test_dynamic_settings($setting_class, $setting_id, $setting_args) {
174
+		$this->assertEquals('WP_Customize_Setting', $setting_class);
175
+		$this->assertInternalType('string', $setting_id);
176
+		$this->assertInternalType('array', $setting_args);
177 177
 		return $setting_class;
178 178
 	}
179 179
 }
Please login to merge, or discard this patch.
tests/core/section.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 	function setUp() {
16 16
 		parent::setUp();
17
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
17
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
18 18
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
19 19
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
20 20
 		$this->manager = $GLOBALS['wp_customize'];
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 	function tearDown() {
25 25
 		$this->manager = null;
26
-		unset( $GLOBALS['wp_customize'] );
26
+		unset($GLOBALS['wp_customize']);
27 27
 		parent::tearDown();
28 28
 	}
29 29
 
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 	 * @see WP_Customize_Section::__construct()
32 32
 	 */
33 33
 	function test_construct_default_args() {
34
-		$section = new WP_Customize_Section( $this->manager, 'foo' );
35
-		$this->assertInternalType( 'int', $section->instance_number );
36
-		$this->assertEquals( $this->manager, $section->manager );
37
-		$this->assertEquals( 'foo', $section->id );
38
-		$this->assertEquals( 160, $section->priority );
39
-		$this->assertEquals( 'edit_theme_options', $section->capability );
40
-		$this->assertEquals( '', $section->theme_supports );
41
-		$this->assertEquals( '', $section->title );
42
-		$this->assertEquals( '', $section->description );
43
-		$this->assertEmpty( $section->panel );
44
-		$this->assertEquals( 'default', $section->type );
45
-		$this->assertEquals( array( $section, 'active_callback' ), $section->active_callback );
34
+		$section = new WP_Customize_Section($this->manager, 'foo');
35
+		$this->assertInternalType('int', $section->instance_number);
36
+		$this->assertEquals($this->manager, $section->manager);
37
+		$this->assertEquals('foo', $section->id);
38
+		$this->assertEquals(160, $section->priority);
39
+		$this->assertEquals('edit_theme_options', $section->capability);
40
+		$this->assertEquals('', $section->theme_supports);
41
+		$this->assertEquals('', $section->title);
42
+		$this->assertEquals('', $section->description);
43
+		$this->assertEmpty($section->panel);
44
+		$this->assertEquals('default', $section->type);
45
+		$this->assertEquals(array($section, 'active_callback'), $section->active_callback);
46 46
 	}
47 47
 
48 48
 	/**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 			'panel' => 'bar',
61 61
 		);
62 62
 
63
-		$this->manager->add_panel( 'bar' );
63
+		$this->manager->add_panel('bar');
64 64
 
65
-		$section = new WP_Customize_Section( $this->manager, 'foo', $args );
66
-		foreach ( $args as $key => $value ) {
67
-			$this->assertEquals( $value, $section->$key );
65
+		$section = new WP_Customize_Section($this->manager, 'foo', $args);
66
+		foreach ($args as $key => $value) {
67
+			$this->assertEquals($value, $section->$key);
68 68
 		}
69 69
 	}
70 70
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @see WP_Customize_Section::__construct()
73 73
 	 */
74 74
 	function test_construct_custom_type() {
75
-		$section = new Custom_Section_Test( $this->manager, 'foo' );
76
-		$this->assertEquals( 'titleless', $section->type );
75
+		$section = new Custom_Section_Test($this->manager, 'foo');
76
+		$this->assertEquals('titleless', $section->type);
77 77
 	}
78 78
 
79 79
 	/**
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * @see WP_Customize_Section::active_callback()
82 82
 	 */
83 83
 	function test_active() {
84
-		$section = new WP_Customize_Section( $this->manager, 'foo' );
85
-		$this->assertTrue( $section->active() );
84
+		$section = new WP_Customize_Section($this->manager, 'foo');
85
+		$this->assertTrue($section->active());
86 86
 
87
-		$section = new WP_Customize_Section( $this->manager, 'foo', array(
87
+		$section = new WP_Customize_Section($this->manager, 'foo', array(
88 88
 			'active_callback' => '__return_false',
89
-		) );
90
-		$this->assertFalse( $section->active() );
91
-		add_filter( 'customize_section_active', array( $this, 'filter_active_test' ), 10, 2 );
92
-		$this->assertTrue( $section->active() );
89
+		));
90
+		$this->assertFalse($section->active());
91
+		add_filter('customize_section_active', array($this, 'filter_active_test'), 10, 2);
92
+		$this->assertTrue($section->active());
93 93
 	}
94 94
 
95 95
 	/**
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param WP_Customize_Section $section
98 98
 	 * @return bool
99 99
 	 */
100
-	function filter_active_test( $active, $section ) {
101
-		$this->assertFalse( $active );
102
-		$this->assertInstanceOf( 'WP_Customize_Section', $section );
100
+	function filter_active_test($active, $section) {
101
+		$this->assertFalse($active);
102
+		$this->assertInstanceOf('WP_Customize_Section', $section);
103 103
 		$active = true;
104 104
 		return $active;
105 105
 	}
@@ -119,102 +119,102 @@  discard block
 block discarded – undo
119 119
 			'active_callback' => '__return_true',
120 120
 		);
121 121
 
122
-		$this->manager->add_panel( 'bar' );
122
+		$this->manager->add_panel('bar');
123 123
 
124
-		$section = new WP_Customize_Section( $this->manager, 'foo', $args );
124
+		$section = new WP_Customize_Section($this->manager, 'foo', $args);
125 125
 		$data = $section->json();
126
-		$this->assertEquals( 'foo', $data['id'] );
127
-		foreach ( array( 'title', 'description', 'priority', 'panel', 'type' ) as $key ) {
128
-			$this->assertEquals( $args[ $key ], $data[ $key ] );
126
+		$this->assertEquals('foo', $data['id']);
127
+		foreach (array('title', 'description', 'priority', 'panel', 'type') as $key) {
128
+			$this->assertEquals($args[$key], $data[$key]);
129 129
 		}
130
-		$this->assertEmpty( $data['content'] );
131
-		$this->assertTrue( $data['active'] );
132
-		$this->assertInternalType( 'int', $data['instanceNumber'] );
130
+		$this->assertEmpty($data['content']);
131
+		$this->assertTrue($data['active']);
132
+		$this->assertInternalType('int', $data['instanceNumber']);
133 133
 	}
134 134
 
135 135
 	/**
136 136
 	 * @see WP_Customize_Section::check_capabilities()
137 137
 	 */
138 138
 	function test_check_capabilities() {
139
-		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
140
-		wp_set_current_user( $user_id );
139
+		$user_id = $this->factory->user->create(array('role' => 'administrator'));
140
+		wp_set_current_user($user_id);
141 141
 
142
-		$section = new WP_Customize_Section( $this->manager, 'foo' );
143
-		$this->assertTrue( $section->check_capabilities() );
142
+		$section = new WP_Customize_Section($this->manager, 'foo');
143
+		$this->assertTrue($section->check_capabilities());
144 144
 		$old_cap = $section->capability;
145 145
 		$section->capability = 'do_not_allow';
146
-		$this->assertFalse( $section->check_capabilities() );
146
+		$this->assertFalse($section->check_capabilities());
147 147
 		$section->capability = $old_cap;
148
-		$this->assertTrue( $section->check_capabilities() );
148
+		$this->assertTrue($section->check_capabilities());
149 149
 		$section->theme_supports = 'impossible_feature';
150
-		$this->assertFalse( $section->check_capabilities() );
150
+		$this->assertFalse($section->check_capabilities());
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * @see WP_Customize_Section::get_content()
155 155
 	 */
156 156
 	function test_get_content() {
157
-		$section = new WP_Customize_Section( $this->manager, 'foo' );
158
-		$this->assertEmpty( $section->get_content() );
157
+		$section = new WP_Customize_Section($this->manager, 'foo');
158
+		$this->assertEmpty($section->get_content());
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * @see WP_Customize_Section::maybe_render()
163 163
 	 */
164 164
 	function test_maybe_render() {
165
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
166
-		$section = new WP_Customize_Section( $this->manager, 'bar' );
167
-		$customize_render_section_count = did_action( 'customize_render_section' );
168
-		add_action( 'customize_render_section', array( $this, 'action_customize_render_section_test' ) );
165
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
166
+		$section = new WP_Customize_Section($this->manager, 'bar');
167
+		$customize_render_section_count = did_action('customize_render_section');
168
+		add_action('customize_render_section', array($this, 'action_customize_render_section_test'));
169 169
 		ob_start();
170 170
 		$section->maybe_render();
171 171
 		$content = ob_get_clean();
172
-		$this->assertTrue( $section->check_capabilities() );
173
-		$this->assertEmpty( $content );
174
-		$this->assertEquals( $customize_render_section_count + 1, did_action( 'customize_render_section' ), 'Unexpected did_action count for customize_render_section' );
175
-		$this->assertEquals( 1, did_action( "customize_render_section_{$section->id}" ), "Unexpected did_action count for customize_render_section_{$section->id}" );
172
+		$this->assertTrue($section->check_capabilities());
173
+		$this->assertEmpty($content);
174
+		$this->assertEquals($customize_render_section_count + 1, did_action('customize_render_section'), 'Unexpected did_action count for customize_render_section');
175
+		$this->assertEquals(1, did_action("customize_render_section_{$section->id}"), "Unexpected did_action count for customize_render_section_{$section->id}");
176 176
 	}
177 177
 
178 178
 	/**
179 179
 	 * @see WP_Customize_Section::maybe_render()
180 180
 	 * @param WP_Customize_Section $section
181 181
 	 */
182
-	function action_customize_render_section_test( $section ) {
183
-		$this->assertInstanceOf( 'WP_Customize_Section', $section );
182
+	function action_customize_render_section_test($section) {
183
+		$this->assertInstanceOf('WP_Customize_Section', $section);
184 184
 	}
185 185
 
186 186
 	/**
187 187
 	 * @see WP_Customize_Section::print_template()
188 188
 	 */
189 189
 	function test_print_templates_standard() {
190
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
190
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
191 191
 
192
-		$section = new WP_Customize_Section( $this->manager, 'baz' );
192
+		$section = new WP_Customize_Section($this->manager, 'baz');
193 193
 		ob_start();
194 194
 		$section->print_template();
195 195
 		$content = ob_get_clean();
196
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-section-default">', $content );
197
-		$this->assertContains( 'accordion-section-title', $content );
198
-		$this->assertContains( 'accordion-section-content', $content );
196
+		$this->assertContains('<script type="text/html" id="tmpl-customize-section-default">', $content);
197
+		$this->assertContains('accordion-section-title', $content);
198
+		$this->assertContains('accordion-section-content', $content);
199 199
 	}
200 200
 
201 201
 	/**
202 202
 	 * @see WP_Customize_Section::print_template()
203 203
 	 */
204 204
 	function test_print_templates_custom() {
205
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
205
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
206 206
 
207
-		$section = new Custom_Section_Test( $this->manager, 'baz' );
207
+		$section = new Custom_Section_Test($this->manager, 'baz');
208 208
 		ob_start();
209 209
 		$section->print_template();
210 210
 		$content = ob_get_clean();
211
-		$this->assertContains( '<script type="text/html" id="tmpl-customize-section-titleless">', $content );
212
-		$this->assertNotContains( 'accordion-section-title', $content );
213
-		$this->assertContains( 'accordion-section-content', $content );
211
+		$this->assertContains('<script type="text/html" id="tmpl-customize-section-titleless">', $content);
212
+		$this->assertNotContains('accordion-section-title', $content);
213
+		$this->assertContains('accordion-section-content', $content);
214 214
 	}
215 215
 }
216 216
 
217
-require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-section.php' );
217
+require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-section.php');
218 218
 //require_once ABSPATH . WPINC . '/class-wp-customize-section.php';
219 219
 class Custom_Section_Test extends WP_Customize_Section {
220 220
 	public $type = 'titleless';
Please login to merge, or discard this patch.
tests/core/nav-menu-setting.php 1 patch
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	function setUp() {
23 23
 		parent::setUp();
24
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
24
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
25 25
 		//require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
26
-		wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
26
+		wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
27 27
 
28 28
 		global $wp_customize;
29 29
 		$this->wp_customize = new WP_Customize_Manager();
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	 * @return array
46 46
 	 */
47 47
 	function get_nav_menu_items_option() {
48
-		return get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
48
+		return get_option('nav_menu_options', array('auto_add' => array()));
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * Test constants and statics.
53 53
 	 */
54 54
 	function test_constants() {
55
-		do_action( 'customize_register', $this->wp_customize );
56
-		$this->assertTrue( taxonomy_exists( WP_Customize_Nav_Menu_Setting::TAXONOMY ) );
55
+		do_action('customize_register', $this->wp_customize);
56
+		$this->assertTrue(taxonomy_exists(WP_Customize_Nav_Menu_Setting::TAXONOMY));
57 57
 	}
58 58
 
59 59
 	/**
@@ -62,49 +62,49 @@  discard block
 block discarded – undo
62 62
 	 * @see WP_Customize_Nav_Menu_Setting::__construct()
63 63
 	 */
64 64
 	function test_construct() {
65
-		do_action( 'customize_register', $this->wp_customize );
66
-
67
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
68
-		$this->assertEquals( 'nav_menu', $setting->type );
69
-		$this->assertEquals( 'postMessage', $setting->transport );
70
-		$this->assertEquals( 123, $setting->term_id );
71
-		$this->assertNull( $setting->previous_term_id );
72
-		$this->assertNull( $setting->update_status );
73
-		$this->assertNull( $setting->update_error );
74
-		$this->assertInternalType( 'array', $setting->default );
75
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
76
-			$this->assertArrayHasKey( $key, $setting->default );
65
+		do_action('customize_register', $this->wp_customize);
66
+
67
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[123]');
68
+		$this->assertEquals('nav_menu', $setting->type);
69
+		$this->assertEquals('postMessage', $setting->transport);
70
+		$this->assertEquals(123, $setting->term_id);
71
+		$this->assertNull($setting->previous_term_id);
72
+		$this->assertNull($setting->update_status);
73
+		$this->assertNull($setting->update_error);
74
+		$this->assertInternalType('array', $setting->default);
75
+		foreach (array('name', 'description', 'parent') as $key) {
76
+			$this->assertArrayHasKey($key, $setting->default);
77 77
 		}
78
-		$this->assertEquals( '', $setting->default['name'] );
79
-		$this->assertEquals( '', $setting->default['description'] );
80
-		$this->assertEquals( 0, $setting->default['parent'] );
78
+		$this->assertEquals('', $setting->default['name']);
79
+		$this->assertEquals('', $setting->default['description']);
80
+		$this->assertEquals(0, $setting->default['parent']);
81 81
 
82 82
 		$exception = null;
83 83
 		try {
84
-			$bad_setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'foo_bar_baz' );
85
-			unset( $bad_setting );
86
-		} catch ( Exception $e ) {
84
+			$bad_setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'foo_bar_baz');
85
+			unset($bad_setting);
86
+		} catch (Exception $e) {
87 87
 			$exception = $e;
88 88
 		}
89
-		$this->assertInstanceOf( 'Exception', $exception );
89
+		$this->assertInstanceOf('Exception', $exception);
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * Test empty constructor.
94 94
 	 */
95 95
 	function test_construct_empty_menus() {
96
-		do_action( 'customize_register', $this->wp_customize );
96
+		do_action('customize_register', $this->wp_customize);
97 97
 		$_wp_customize = $this->wp_customize;
98
-		unset( $_wp_customize->nav_menus );
98
+		unset($_wp_customize->nav_menus);
99 99
 
100 100
 		$exception = null;
101 101
 		try {
102
-			$bad_setting = new WP_Customize_Nav_Menu_Setting( $_wp_customize, 'nav_menu_item[123]' );
103
-			unset( $bad_setting );
104
-		} catch ( Exception $e ) {
102
+			$bad_setting = new WP_Customize_Nav_Menu_Setting($_wp_customize, 'nav_menu_item[123]');
103
+			unset($bad_setting);
104
+		} catch (Exception $e) {
105 105
 			$exception = $e;
106 106
 		}
107
-		$this->assertInstanceOf( 'Exception', $exception );
107
+		$this->assertInstanceOf('Exception', $exception);
108 108
 	}
109 109
 
110 110
 	/**
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	 * @see WP_Customize_Nav_Menu_Setting::__construct()
114 114
 	 */
115 115
 	function test_construct_placeholder() {
116
-		do_action( 'customize_register', $this->wp_customize );
116
+		do_action('customize_register', $this->wp_customize);
117 117
 		$default = array(
118 118
 			'name' => 'Lorem',
119 119
 			'description' => 'ipsum',
120 120
 			'parent' => 123,
121 121
 		);
122
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[-5]', compact( 'default' ) );
122
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[-5]', compact('default'));
123 123
 		$this->assertEquals( -5, $setting->term_id );
124
-		$this->assertEquals( $default, $setting->default );
124
+		$this->assertEquals($default, $setting->default);
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,33 +130,33 @@  discard block
 block discarded – undo
130 130
 	 * @see WP_Customize_Nav_Menu_Setting::value()
131 131
 	 */
132 132
 	function test_value() {
133
-		do_action( 'customize_register', $this->wp_customize );
133
+		do_action('customize_register', $this->wp_customize);
134 134
 
135 135
 		$menu_name = 'Test 123';
136
-		$parent_menu_id = wp_create_nav_menu( "Parent $menu_name" );
136
+		$parent_menu_id = wp_create_nav_menu("Parent $menu_name");
137 137
 		$description = 'Hello my world.';
138
-		$menu_id = wp_update_nav_menu_object( 0, array(
138
+		$menu_id = wp_update_nav_menu_object(0, array(
139 139
 			'menu-name' => $menu_name,
140 140
 			'parent' => $parent_menu_id,
141 141
 			'description' => $description,
142
-		) );
142
+		));
143 143
 
144 144
 		$setting_id = "nav_menu[$menu_id]";
145
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
145
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
146 146
 
147 147
 		$value = $setting->value();
148
-		$this->assertInternalType( 'array', $value );
149
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
150
-			$this->assertArrayHasKey( $key, $value );
148
+		$this->assertInternalType('array', $value);
149
+		foreach (array('name', 'description', 'parent') as $key) {
150
+			$this->assertArrayHasKey($key, $value);
151 151
 		}
152
-		$this->assertEquals( $menu_name, $value['name'] );
153
-		$this->assertEquals( $description, $value['description'] );
154
-		$this->assertEquals( $parent_menu_id, $value['parent'] );
152
+		$this->assertEquals($menu_name, $value['name']);
153
+		$this->assertEquals($description, $value['description']);
154
+		$this->assertEquals($parent_menu_id, $value['parent']);
155 155
 
156 156
 		$new_menu_name = 'Foo';
157
-		wp_update_nav_menu_object( $menu_id, array( 'menu-name' => $new_menu_name ) );
157
+		wp_update_nav_menu_object($menu_id, array('menu-name' => $new_menu_name));
158 158
 		$updated_value = $setting->value();
159
-		$this->assertEquals( $new_menu_name, $updated_value['name'] );
159
+		$this->assertEquals($new_menu_name, $updated_value['name']);
160 160
 	}
161 161
 
162 162
 	/**
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
166 166
 	 */
167 167
 	function test_preview_updated() {
168
-		do_action( 'customize_register', $this->wp_customize );
168
+		do_action('customize_register', $this->wp_customize);
169 169
 
170
-		$menu_id = wp_update_nav_menu_object( 0, array(
170
+		$menu_id = wp_update_nav_menu_object(0, array(
171 171
 			'menu-name' => 'Name 1',
172 172
 			'description' => 'Description 1',
173 173
 			'parent' => 0,
174
-		) );
174
+		));
175 175
 		$setting_id = "nav_menu[$menu_id]";
176
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
176
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
177 177
 
178 178
 		$nav_menu_options = $this->get_nav_menu_items_option();
179
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
179
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
180 180
 
181 181
 		$post_value = array(
182 182
 			'name' => 'Name 2',
@@ -184,41 +184,41 @@  discard block
 block discarded – undo
184 184
 			'parent' => 1,
185 185
 			'auto_add' => true,
186 186
 		);
187
-		$this->wp_customize->set_post_value( $setting_id, $post_value );
187
+		$this->wp_customize->set_post_value($setting_id, $post_value);
188 188
 
189 189
 		$value = $setting->value();
190
-		$this->assertEquals( 'Name 1', $value['name'] );
191
-		$this->assertEquals( 'Description 1', $value['description'] );
192
-		$this->assertEquals( 0, $value['parent'] );
190
+		$this->assertEquals('Name 1', $value['name']);
191
+		$this->assertEquals('Description 1', $value['description']);
192
+		$this->assertEquals(0, $value['parent']);
193 193
 
194
-		$term = (array) wp_get_nav_menu_object( $menu_id );
194
+		$term = (array) wp_get_nav_menu_object($menu_id);
195 195
 
196 196
 		$this->assertEqualSets(
197
-			wp_array_slice_assoc( $value, array( 'name', 'description', 'parent' ) ),
198
-			wp_array_slice_assoc( $term, array( 'name', 'description', 'parent' ) )
197
+			wp_array_slice_assoc($value, array('name', 'description', 'parent')),
198
+			wp_array_slice_assoc($term, array('name', 'description', 'parent'))
199 199
 		);
200 200
 
201 201
 		$setting->preview();
202 202
 		$value = $setting->value();
203
-		$this->assertEquals( 'Name 2', $value['name'] );
204
-		$this->assertEquals( 'Description 2', $value['description'] );
205
-		$this->assertEquals( 1, $value['parent'] );
206
-		$term = (array) wp_get_nav_menu_object( $menu_id );
207
-		$this->assertEqualSets( $value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
203
+		$this->assertEquals('Name 2', $value['name']);
204
+		$this->assertEquals('Description 2', $value['description']);
205
+		$this->assertEquals(1, $value['parent']);
206
+		$term = (array) wp_get_nav_menu_object($menu_id);
207
+		$this->assertEqualSets($value, wp_array_slice_assoc($term, array_keys($value)));
208 208
 
209
-		$menu_object = wp_get_nav_menu_object( $menu_id );
210
-		$this->assertEquals( (object) $term, $menu_object );
211
-		$this->assertEquals( $post_value['name'], $menu_object->name );
209
+		$menu_object = wp_get_nav_menu_object($menu_id);
210
+		$this->assertEquals((object) $term, $menu_object);
211
+		$this->assertEquals($post_value['name'], $menu_object->name);
212 212
 
213
-		$nav_menu_options = get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
214
-		$this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
213
+		$nav_menu_options = get_option('nav_menu_options', array('auto_add' => array()));
214
+		$this->assertContains($menu_id, $nav_menu_options['auto_add']);
215 215
 
216 216
 		$menus = wp_get_nav_menus();
217
-		$menus_ids = wp_list_pluck( $menus, 'term_id' );
218
-		$i = array_search( $menu_id, $menus_ids );
219
-		$this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
220
-		$filtered_menu = $menus[ $i ];
221
-		$this->assertEquals( 'Name 2', $filtered_menu->name );
217
+		$menus_ids = wp_list_pluck($menus, 'term_id');
218
+		$i = array_search($menu_id, $menus_ids);
219
+		$this->assertInternalType('int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()');
220
+		$filtered_menu = $menus[$i];
221
+		$this->assertEquals('Name 2', $filtered_menu->name);
222 222
 	}
223 223
 
224 224
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
228 228
 	 */
229 229
 	function test_preview_inserted() {
230
-		do_action( 'customize_register', $this->wp_customize );
230
+		do_action('customize_register', $this->wp_customize);
231 231
 
232 232
 		$menu_id = -123;
233 233
 		$post_value = array(
@@ -237,33 +237,33 @@  discard block
 block discarded – undo
237 237
 			'auto_add' => false,
238 238
 		);
239 239
 		$setting_id = "nav_menu[$menu_id]";
240
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
240
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
241 241
 
242
-		$this->wp_customize->set_post_value( $setting->id, $post_value );
242
+		$this->wp_customize->set_post_value($setting->id, $post_value);
243 243
 		$setting->preview();
244 244
 		$value = $setting->value();
245
-		$this->assertEquals( $post_value, $value );
245
+		$this->assertEquals($post_value, $value);
246 246
 
247
-		$term = (array) wp_get_nav_menu_object( $menu_id );
248
-		$this->assertNotEmpty( $term );
249
-		$this->assertNotInstanceOf( 'WP_Error', $term );
250
-		$this->assertEqualSets( $post_value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
251
-		$this->assertEquals( $menu_id, $term['term_id'] );
252
-		$this->assertEquals( $menu_id, $term['term_taxonomy_id'] );
247
+		$term = (array) wp_get_nav_menu_object($menu_id);
248
+		$this->assertNotEmpty($term);
249
+		$this->assertNotInstanceOf('WP_Error', $term);
250
+		$this->assertEqualSets($post_value, wp_array_slice_assoc($term, array_keys($value)));
251
+		$this->assertEquals($menu_id, $term['term_id']);
252
+		$this->assertEquals($menu_id, $term['term_taxonomy_id']);
253 253
 
254
-		$menu_object = wp_get_nav_menu_object( $menu_id );
255
-		$this->assertEquals( (object) $term, $menu_object );
256
-		$this->assertEquals( $post_value['name'], $menu_object->name );
254
+		$menu_object = wp_get_nav_menu_object($menu_id);
255
+		$this->assertEquals((object) $term, $menu_object);
256
+		$this->assertEquals($post_value['name'], $menu_object->name);
257 257
 
258 258
 		$nav_menu_options = $this->get_nav_menu_items_option();
259
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
259
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
260 260
 
261 261
 		$menus = wp_get_nav_menus();
262
-		$menus_ids = wp_list_pluck( $menus, 'term_id' );
263
-		$i = array_search( $menu_id, $menus_ids );
264
-		$this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
265
-		$filtered_menu = $menus[ $i ];
266
-		$this->assertEquals( 'New Menu Name 1', $filtered_menu->name );
262
+		$menus_ids = wp_list_pluck($menus, 'term_id');
263
+		$i = array_search($menu_id, $menus_ids);
264
+		$this->assertInternalType('int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()');
265
+		$filtered_menu = $menus[$i];
266
+		$this->assertEquals('New Menu Name 1', $filtered_menu->name);
267 267
 	}
268 268
 
269 269
 	/**
@@ -272,32 +272,32 @@  discard block
 block discarded – undo
272 272
 	 * @see WP_Customize_Nav_Menu_Setting::preview()
273 273
 	 */
274 274
 	function test_preview_deleted() {
275
-		do_action( 'customize_register', $this->wp_customize );
275
+		do_action('customize_register', $this->wp_customize);
276 276
 
277
-		$menu_id = wp_update_nav_menu_object( 0, array(
277
+		$menu_id = wp_update_nav_menu_object(0, array(
278 278
 			'menu-name' => 'Name 1',
279 279
 			'description' => 'Description 1',
280 280
 			'parent' => 0,
281
-		) );
281
+		));
282 282
 		$setting_id = "nav_menu[$menu_id]";
283
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
283
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
284 284
 		$nav_menu_options = $this->get_nav_menu_items_option();
285 285
 		$nav_menu_options['auto_add'][] = $menu_id;
286
-		update_option( 'nav_menu_options', $nav_menu_options );
286
+		update_option('nav_menu_options', $nav_menu_options);
287 287
 
288 288
 		$nav_menu_options = $this->get_nav_menu_items_option();
289
-		$this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
289
+		$this->assertContains($menu_id, $nav_menu_options['auto_add']);
290 290
 
291
-		$this->wp_customize->set_post_value( $setting_id, false );
291
+		$this->wp_customize->set_post_value($setting_id, false);
292 292
 
293
-		$this->assertInternalType( 'array', $setting->value() );
294
-		$this->assertInternalType( 'object', wp_get_nav_menu_object( $menu_id ) );
293
+		$this->assertInternalType('array', $setting->value());
294
+		$this->assertInternalType('object', wp_get_nav_menu_object($menu_id));
295 295
 		$setting->preview();
296
-		$this->assertFalse( $setting->value() );
297
-		$this->assertFalse( wp_get_nav_menu_object( $menu_id ) );
296
+		$this->assertFalse($setting->value());
297
+		$this->assertFalse(wp_get_nav_menu_object($menu_id));
298 298
 
299 299
 		$nav_menu_options = $this->get_nav_menu_items_option();
300
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
300
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
301 301
 	}
302 302
 
303 303
 	/**
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	 * @see WP_Customize_Nav_Menu_Setting::sanitize()
307 307
 	 */
308 308
 	function test_sanitize() {
309
-		do_action( 'customize_register', $this->wp_customize );
310
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
309
+		do_action('customize_register', $this->wp_customize);
310
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, 'nav_menu[123]');
311 311
 
312
-		$this->assertNull( $setting->sanitize( 'not an array' ) );
313
-		$this->assertNull( $setting->sanitize( 123 ) );
312
+		$this->assertNull($setting->sanitize('not an array'));
313
+		$this->assertNull($setting->sanitize(123));
314 314
 
315 315
 		$value = array(
316 316
 			'name' => ' Hello <b>world</b> ',
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 			'auto_add' => true,
320 320
 			'extra' => 'ignored',
321 321
 		);
322
-		$sanitized = $setting->sanitize( $value );
323
-		$this->assertEquals( 'Hello &lt;b&gt;world&lt;/b&gt;', $sanitized['name'] );
324
-		$this->assertEquals( 'New line', $sanitized['description'] );
325
-		$this->assertEquals( 0, $sanitized['parent'] );
326
-		$this->assertEquals( true, $sanitized['auto_add'] );
327
-		$this->assertEqualSets( array( 'name', 'description', 'parent', 'auto_add' ), array_keys( $sanitized ) );
322
+		$sanitized = $setting->sanitize($value);
323
+		$this->assertEquals('Hello &lt;b&gt;world&lt;/b&gt;', $sanitized['name']);
324
+		$this->assertEquals('New line', $sanitized['description']);
325
+		$this->assertEquals(0, $sanitized['parent']);
326
+		$this->assertEquals(true, $sanitized['auto_add']);
327
+		$this->assertEqualSets(array('name', 'description', 'parent', 'auto_add'), array_keys($sanitized));
328 328
 
329 329
 		$value['name'] = '    '; // Blank spaces.
330
-		$sanitized = $setting->sanitize( $value );
331
-		$this->assertEquals( '(unnamed)', $sanitized['name'] );
330
+		$sanitized = $setting->sanitize($value);
331
+		$this->assertEquals('(unnamed)', $sanitized['name']);
332 332
 	}
333 333
 
334 334
 	/**
@@ -337,19 +337,19 @@  discard block
 block discarded – undo
337 337
 	 * @see WP_Customize_Nav_Menu_Setting::update()
338 338
 	 */
339 339
 	function test_save_updated() {
340
-		do_action( 'customize_register', $this->wp_customize );
340
+		do_action('customize_register', $this->wp_customize);
341 341
 
342
-		$menu_id = wp_update_nav_menu_object( 0, array(
342
+		$menu_id = wp_update_nav_menu_object(0, array(
343 343
 			'menu-name' => 'Name 1',
344 344
 			'description' => 'Description 1',
345 345
 			'parent' => 0,
346
-		) );
346
+		));
347 347
 		$nav_menu_options = $this->get_nav_menu_items_option();
348 348
 		$nav_menu_options['auto_add'][] = $menu_id;
349
-		update_option( 'nav_menu_options', $nav_menu_options );
349
+		update_option('nav_menu_options', $nav_menu_options);
350 350
 
351 351
 		$setting_id = "nav_menu[$menu_id]";
352
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
352
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
353 353
 
354 354
 		$auto_add = false;
355 355
 		$new_value = array(
@@ -359,36 +359,36 @@  discard block
 block discarded – undo
359 359
 			'auto_add' => $auto_add,
360 360
 		);
361 361
 
362
-		$this->wp_customize->set_post_value( $setting_id, $new_value );
362
+		$this->wp_customize->set_post_value($setting_id, $new_value);
363 363
 		$setting->save();
364 364
 
365
-		$menu_object = wp_get_nav_menu_object( $menu_id );
366
-		foreach ( array( 'name', 'description', 'parent' ) as $key ) {
367
-			$this->assertEquals( $new_value[ $key ], $menu_object->$key );
365
+		$menu_object = wp_get_nav_menu_object($menu_id);
366
+		foreach (array('name', 'description', 'parent') as $key) {
367
+			$this->assertEquals($new_value[$key], $menu_object->$key);
368 368
 		}
369 369
 		$this->assertEqualSets(
370
-			wp_array_slice_assoc( $new_value, array( 'name', 'description', 'parent' ) ),
371
-			wp_array_slice_assoc( (array) $menu_object, array( 'name', 'description', 'parent' ) )
370
+			wp_array_slice_assoc($new_value, array('name', 'description', 'parent')),
371
+			wp_array_slice_assoc((array) $menu_object, array('name', 'description', 'parent'))
372 372
 		);
373
-		$this->assertEquals( $new_value, $setting->value() );
374
-
375
-		$save_response = apply_filters( 'customize_save_response', array() );
376
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
377
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
378
-		$this->assertArrayHasKey( 'term_id', $update_result );
379
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
380
-		$this->assertArrayHasKey( 'error', $update_result );
381
-		$this->assertArrayHasKey( 'status', $update_result );
382
-		$this->assertArrayHasKey( 'saved_value', $update_result );
383
-		$this->assertEquals( $new_value, $update_result['saved_value'] );
384
-
385
-		$this->assertEquals( $menu_id, $update_result['term_id'] );
386
-		$this->assertNull( $update_result['previous_term_id'] );
387
-		$this->assertNull( $update_result['error'] );
388
-		$this->assertEquals( 'updated', $update_result['status'] );
373
+		$this->assertEquals($new_value, $setting->value());
374
+
375
+		$save_response = apply_filters('customize_save_response', array());
376
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
377
+		$update_result = array_shift($save_response['nav_menu_updates']);
378
+		$this->assertArrayHasKey('term_id', $update_result);
379
+		$this->assertArrayHasKey('previous_term_id', $update_result);
380
+		$this->assertArrayHasKey('error', $update_result);
381
+		$this->assertArrayHasKey('status', $update_result);
382
+		$this->assertArrayHasKey('saved_value', $update_result);
383
+		$this->assertEquals($new_value, $update_result['saved_value']);
384
+
385
+		$this->assertEquals($menu_id, $update_result['term_id']);
386
+		$this->assertNull($update_result['previous_term_id']);
387
+		$this->assertNull($update_result['error']);
388
+		$this->assertEquals('updated', $update_result['status']);
389 389
 
390 390
 		$nav_menu_options = $this->get_nav_menu_items_option();
391
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
391
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
392 392
 	}
393 393
 
394 394
 	/**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * @see WP_Customize_Nav_Menu_Setting::update()
398 398
 	 */
399 399
 	function test_save_inserted() {
400
-		do_action( 'customize_register', $this->wp_customize );
400
+		do_action('customize_register', $this->wp_customize);
401 401
 
402 402
 		$menu_id = -123;
403 403
 		$post_value = array(
@@ -407,37 +407,37 @@  discard block
 block discarded – undo
407 407
 			'auto_add' => true,
408 408
 		);
409 409
 		$setting_id = "nav_menu[$menu_id]";
410
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
410
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
411 411
 
412
-		$this->wp_customize->set_post_value( $setting->id, $post_value );
412
+		$this->wp_customize->set_post_value($setting->id, $post_value);
413 413
 
414
-		$this->assertNull( $setting->previous_term_id );
415
-		$this->assertLessThan( 0, $setting->term_id );
414
+		$this->assertNull($setting->previous_term_id);
415
+		$this->assertLessThan(0, $setting->term_id);
416 416
 		$setting->save();
417
-		$this->assertEquals( $menu_id, $setting->previous_term_id );
418
-		$this->assertGreaterThan( 0, $setting->term_id );
417
+		$this->assertEquals($menu_id, $setting->previous_term_id);
418
+		$this->assertGreaterThan(0, $setting->term_id);
419 419
 
420 420
 		$nav_menu_options = $this->get_nav_menu_items_option();
421
-		$this->assertContains( $setting->term_id, $nav_menu_options['auto_add'] );
422
-
423
-		$menu = wp_get_nav_menu_object( $setting->term_id );
424
-		unset( $post_value['auto_add'] );
425
-		$this->assertEqualSets( $post_value, wp_array_slice_assoc( (array) $menu, array_keys( $post_value ) ) );
426
-
427
-		$save_response = apply_filters( 'customize_save_response', array() );
428
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
429
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
430
-		$this->assertArrayHasKey( 'term_id', $update_result );
431
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
432
-		$this->assertArrayHasKey( 'error', $update_result );
433
-		$this->assertArrayHasKey( 'status', $update_result );
434
-		$this->assertArrayHasKey( 'saved_value', $update_result );
435
-		$this->assertEquals( $setting->value(), $update_result['saved_value'] );
436
-
437
-		$this->assertEquals( $menu->term_id, $update_result['term_id'] );
438
-		$this->assertEquals( $menu_id, $update_result['previous_term_id'] );
439
-		$this->assertNull( $update_result['error'] );
440
-		$this->assertEquals( 'inserted', $update_result['status'] );
421
+		$this->assertContains($setting->term_id, $nav_menu_options['auto_add']);
422
+
423
+		$menu = wp_get_nav_menu_object($setting->term_id);
424
+		unset($post_value['auto_add']);
425
+		$this->assertEqualSets($post_value, wp_array_slice_assoc((array) $menu, array_keys($post_value)));
426
+
427
+		$save_response = apply_filters('customize_save_response', array());
428
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
429
+		$update_result = array_shift($save_response['nav_menu_updates']);
430
+		$this->assertArrayHasKey('term_id', $update_result);
431
+		$this->assertArrayHasKey('previous_term_id', $update_result);
432
+		$this->assertArrayHasKey('error', $update_result);
433
+		$this->assertArrayHasKey('status', $update_result);
434
+		$this->assertArrayHasKey('saved_value', $update_result);
435
+		$this->assertEquals($setting->value(), $update_result['saved_value']);
436
+
437
+		$this->assertEquals($menu->term_id, $update_result['term_id']);
438
+		$this->assertEquals($menu_id, $update_result['previous_term_id']);
439
+		$this->assertNull($update_result['error']);
440
+		$this->assertEquals('inserted', $update_result['status']);
441 441
 	}
442 442
 
443 443
 	/**
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 	 * @see WP_Customize_Nav_Menu_Setting::update()
447 447
 	 */
448 448
 	function test_save_inserted_conflicted_name() {
449
-		do_action( 'customize_register', $this->wp_customize );
449
+		do_action('customize_register', $this->wp_customize);
450 450
 
451 451
 		$menu_name = 'Foo';
452
-		wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );
452
+		wp_update_nav_menu_object(0, array('menu-name' => $menu_name));
453 453
 
454 454
 		$menu_id = -123;
455 455
 		$setting_id = "nav_menu[$menu_id]";
456
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
457
-		$this->wp_customize->set_post_value( $setting->id, array( 'name' => $menu_name ) );
456
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
457
+		$this->wp_customize->set_post_value($setting->id, array('name' => $menu_name));
458 458
 		$setting->save();
459 459
 
460 460
 		$expected_resolved_menu_name = "$menu_name (2)";
461
-		$new_menu = wp_get_nav_menu_object( $setting->term_id );
462
-		$this->assertEquals( $expected_resolved_menu_name, $new_menu->name );
461
+		$new_menu = wp_get_nav_menu_object($setting->term_id);
462
+		$this->assertEquals($expected_resolved_menu_name, $new_menu->name);
463 463
 
464
-		$save_response = apply_filters( 'customize_save_response', array() );
465
-		$this->assertEquals( $expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name'] );
464
+		$save_response = apply_filters('customize_save_response', array());
465
+		$this->assertEquals($expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name']);
466 466
 	}
467 467
 
468 468
 	/**
@@ -471,41 +471,41 @@  discard block
 block discarded – undo
471 471
 	 * @see WP_Customize_Nav_Menu_Setting::update()
472 472
 	 */
473 473
 	function test_save_deleted() {
474
-		do_action( 'customize_register', $this->wp_customize );
474
+		do_action('customize_register', $this->wp_customize);
475 475
 
476 476
 		$menu_name = 'Lorem Ipsum';
477
-		$menu_id = wp_create_nav_menu( $menu_name );
477
+		$menu_id = wp_create_nav_menu($menu_name);
478 478
 		$setting_id = "nav_menu[$menu_id]";
479
-		$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
479
+		$setting = new WP_Customize_Nav_Menu_Setting($this->wp_customize, $setting_id);
480 480
 		$nav_menu_options = $this->get_nav_menu_items_option();
481 481
 		$nav_menu_options['auto_add'][] = $menu_id;
482
-		update_option( 'nav_menu_options', $nav_menu_options );
482
+		update_option('nav_menu_options', $nav_menu_options);
483 483
 
484
-		$menu = wp_get_nav_menu_object( $menu_id );
485
-		$this->assertEquals( $menu_name, $menu->name );
484
+		$menu = wp_get_nav_menu_object($menu_id);
485
+		$this->assertEquals($menu_name, $menu->name);
486 486
 
487
-		$this->wp_customize->set_post_value( $setting_id, false );
487
+		$this->wp_customize->set_post_value($setting_id, false);
488 488
 		$setting->save();
489 489
 
490
-		$this->assertFalse( wp_get_nav_menu_object( $menu_id ) );
490
+		$this->assertFalse(wp_get_nav_menu_object($menu_id));
491 491
 
492
-		$save_response = apply_filters( 'customize_save_response', array() );
493
-		$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
494
-		$update_result = array_shift( $save_response['nav_menu_updates'] );
495
-		$this->assertArrayHasKey( 'term_id', $update_result );
496
-		$this->assertArrayHasKey( 'previous_term_id', $update_result );
497
-		$this->assertArrayHasKey( 'error', $update_result );
498
-		$this->assertArrayHasKey( 'status', $update_result );
499
-		$this->assertArrayHasKey( 'saved_value', $update_result );
500
-		$this->assertNull( $update_result['saved_value'] );
492
+		$save_response = apply_filters('customize_save_response', array());
493
+		$this->assertArrayHasKey('nav_menu_updates', $save_response);
494
+		$update_result = array_shift($save_response['nav_menu_updates']);
495
+		$this->assertArrayHasKey('term_id', $update_result);
496
+		$this->assertArrayHasKey('previous_term_id', $update_result);
497
+		$this->assertArrayHasKey('error', $update_result);
498
+		$this->assertArrayHasKey('status', $update_result);
499
+		$this->assertArrayHasKey('saved_value', $update_result);
500
+		$this->assertNull($update_result['saved_value']);
501 501
 
502
-		$this->assertEquals( $menu_id, $update_result['term_id'] );
503
-		$this->assertNull( $update_result['previous_term_id'] );
504
-		$this->assertNull( $update_result['error'] );
505
-		$this->assertEquals( 'deleted', $update_result['status'] );
502
+		$this->assertEquals($menu_id, $update_result['term_id']);
503
+		$this->assertNull($update_result['previous_term_id']);
504
+		$this->assertNull($update_result['error']);
505
+		$this->assertEquals('deleted', $update_result['status']);
506 506
 
507 507
 		$nav_menu_options = $this->get_nav_menu_items_option();
508
-		$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
508
+		$this->assertNotContains($menu_id, $nav_menu_options['auto_add']);
509 509
 	}
510 510
 
511 511
 }
Please login to merge, or discard this patch.
tests/core/widgets.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@  discard block
 block discarded – undo
14 14
 
15 15
 	function setUp() {
16 16
 		parent::setUp();
17
-		require_once( WP_FIELDS_API_DIR . 'implementation/wp-includes/class-wp-customize-manager.php' );
17
+		require_once(WP_FIELDS_API_DIR.'implementation/wp-includes/class-wp-customize-manager.php');
18 18
 		//require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
19 19
 		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
20 20
 		$this->manager = $GLOBALS['wp_customize'];
21 21
 
22
-		unset( $GLOBALS['_wp_sidebars_widgets'] ); // clear out cache set by wp_get_sidebars_widgets()
22
+		unset($GLOBALS['_wp_sidebars_widgets']); // clear out cache set by wp_get_sidebars_widgets()
23 23
 		$sidebars_widgets = wp_get_sidebars_widgets();
24
-		$this->assertEqualSets( array( 'wp_inactive_widgets', 'sidebar-1' ), array_keys( wp_get_sidebars_widgets() ) );
25
-		$this->assertContains( 'search-2', $sidebars_widgets['sidebar-1'] );
26
-		$this->assertContains( 'categories-2', $sidebars_widgets['sidebar-1'] );
27
-		$this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
28
-		$widget_categories = get_option( 'widget_categories' );
29
-		$this->assertArrayHasKey( 2, $widget_categories );
30
-		$this->assertEquals( '', $widget_categories[2]['title'] );
31
-
32
-		remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway
33
-
34
-		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
35
-		wp_set_current_user( $user_id );
24
+		$this->assertEqualSets(array('wp_inactive_widgets', 'sidebar-1'), array_keys(wp_get_sidebars_widgets()));
25
+		$this->assertContains('search-2', $sidebars_widgets['sidebar-1']);
26
+		$this->assertContains('categories-2', $sidebars_widgets['sidebar-1']);
27
+		$this->assertArrayHasKey(2, get_option('widget_search'));
28
+		$widget_categories = get_option('widget_categories');
29
+		$this->assertArrayHasKey(2, $widget_categories);
30
+		$this->assertEquals('', $widget_categories[2]['title']);
31
+
32
+		remove_action('after_setup_theme', 'twentyfifteen_setup'); // @todo We should not be including a theme anyway
33
+
34
+		$user_id = $this->factory->user->create(array('role' => 'administrator'));
35
+		wp_set_current_user($user_id);
36 36
 	}
37 37
 
38 38
 	function tearDown() {
39 39
 		$this->manager = null;
40
-		unset( $GLOBALS['wp_customize'] );
41
-		unset( $GLOBALS['wp_scripts'] );
40
+		unset($GLOBALS['wp_customize']);
41
+		unset($GLOBALS['wp_scripts']);
42 42
 		parent::tearDown();
43 43
 	}
44 44
 
45
-	function set_customized_post_data( $customized ) {
46
-		$_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
45
+	function set_customized_post_data($customized) {
46
+		$_POST['customized'] = wp_slash(wp_json_encode($customized));
47 47
 	}
48 48
 
49 49
 	function do_customize_boot_actions() {
50 50
 		$_SERVER['REQUEST_METHOD'] = 'POST';
51
-		do_action( 'setup_theme' );
52
-		$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() );
53
-		do_action( 'after_setup_theme' );
54
-		do_action( 'init' );
55
-		do_action( 'wp_loaded' );
56
-		do_action( 'wp', $GLOBALS['wp'] );
51
+		do_action('setup_theme');
52
+		$_REQUEST['nonce'] = wp_create_nonce('preview-customize_'.$this->manager->theme()->get_stylesheet());
53
+		do_action('after_setup_theme');
54
+		do_action('init');
55
+		do_action('wp_loaded');
56
+		do_action('wp', $GLOBALS['wp']);
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * Test WP_Customize_Widgets::__construct()
61 61
 	 */
62 62
 	function test_construct() {
63
-		$this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
64
-		$this->assertEquals( $this->manager, $this->manager->widgets->manager );
63
+		$this->assertInstanceOf('WP_Customize_Widgets', $this->manager->widgets);
64
+		$this->assertEquals($this->manager, $this->manager->widgets->manager);
65 65
 	}
66 66
 
67 67
 	/**
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
 			),
84 84
 		);
85 85
 		$customized = array();
86
-		foreach ( $raw_widget_customized as $setting_id => $instance ) {
87
-			$customized[ $setting_id ] = $this->manager->widgets->sanitize_widget_js_instance( $instance );
86
+		foreach ($raw_widget_customized as $setting_id => $instance) {
87
+			$customized[$setting_id] = $this->manager->widgets->sanitize_widget_js_instance($instance);
88 88
 		}
89 89
 
90
-		$this->set_customized_post_data( $customized );
90
+		$this->set_customized_post_data($customized);
91 91
 		$this->do_customize_boot_actions();
92
-		$this->assertTrue( is_customize_preview() );
92
+		$this->assertTrue(is_customize_preview());
93 93
 
94
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_categories[2]' ), 'Expected setting for pre-existing widget category-2, being customized.' );
95
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_search[2]' ), 'Expected setting for pre-existing widget search-2, not being customized.' );
96
-		$this->assertNotEmpty( $this->manager->get_setting( 'widget_search[3]' ), 'Expected dynamic setting for non-existing widget search-3, being customized.' );
94
+		$this->assertNotEmpty($this->manager->get_setting('widget_categories[2]'), 'Expected setting for pre-existing widget category-2, being customized.');
95
+		$this->assertNotEmpty($this->manager->get_setting('widget_search[2]'), 'Expected setting for pre-existing widget search-2, not being customized.');
96
+		$this->assertNotEmpty($this->manager->get_setting('widget_search[3]'), 'Expected dynamic setting for non-existing widget search-3, being customized.');
97 97
 
98
-		$widget_categories = get_option( 'widget_categories' );
99
-		$this->assertEquals( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' );
98
+		$widget_categories = get_option('widget_categories');
99
+		$this->assertEquals($raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.');
100 100
 	}
101 101
 
102 102
 	/**
@@ -104,68 +104,68 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	function test_get_setting_args() {
106 106
 
107
-		add_filter( 'widget_customizer_setting_args', array( $this, 'filter_widget_customizer_setting_args' ), 10, 2 );
107
+		add_filter('widget_customizer_setting_args', array($this, 'filter_widget_customizer_setting_args'), 10, 2);
108 108
 
109 109
 		$default_args = array(
110 110
 			'type' => 'option',
111 111
 			'capability' => 'edit_theme_options',
112 112
 			'transport' => 'refresh',
113 113
 			'default' => array(),
114
-			'sanitize_callback' => array( $this->manager->widgets, 'sanitize_widget_instance' ),
115
-			'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_widget_js_instance' ),
114
+			'sanitize_callback' => array($this->manager->widgets, 'sanitize_widget_instance'),
115
+			'sanitize_js_callback' => array($this->manager->widgets, 'sanitize_widget_js_instance'),
116 116
 		);
117 117
 
118
-		$args = $this->manager->widgets->get_setting_args( 'widget_foo[2]' );
119
-		foreach ( $default_args as $key => $default_value ) {
120
-			$this->assertEquals( $default_value, $args[ $key ] );
118
+		$args = $this->manager->widgets->get_setting_args('widget_foo[2]');
119
+		foreach ($default_args as $key => $default_value) {
120
+			$this->assertEquals($default_value, $args[$key]);
121 121
 		}
122
-		$this->assertEquals( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] );
122
+		$this->assertEquals('WIDGET_FOO[2]', $args['uppercase_id_set_by_filter']);
123 123
 
124 124
 		$override_args = array(
125 125
 			'type' => 'theme_mod',
126 126
 			'capability' => 'edit_posts',
127 127
 			'transport' => 'postMessage',
128
-			'default' => array( 'title' => 'asd' ),
128
+			'default' => array('title' => 'asd'),
129 129
 			'sanitize_callback' => '__return_empty_array',
130 130
 			'sanitize_js_callback' => '__return_empty_array',
131 131
 		);
132
-		$args = $this->manager->widgets->get_setting_args( 'widget_bar[3]', $override_args );
133
-		foreach ( $override_args as $key => $override_value ) {
134
-			$this->assertEquals( $override_value, $args[ $key ] );
132
+		$args = $this->manager->widgets->get_setting_args('widget_bar[3]', $override_args);
133
+		foreach ($override_args as $key => $override_value) {
134
+			$this->assertEquals($override_value, $args[$key]);
135 135
 		}
136
-		$this->assertEquals( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] );
136
+		$this->assertEquals('WIDGET_BAR[3]', $args['uppercase_id_set_by_filter']);
137 137
 
138 138
 		$default_args = array(
139 139
 			'type' => 'option',
140 140
 			'capability' => 'edit_theme_options',
141 141
 			'transport' => 'refresh',
142 142
 			'default' => array(),
143
-			'sanitize_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets' ),
144
-			'sanitize_js_callback' => array( $this->manager->widgets, 'sanitize_sidebar_widgets_js_instance' ),
143
+			'sanitize_callback' => array($this->manager->widgets, 'sanitize_sidebar_widgets'),
144
+			'sanitize_js_callback' => array($this->manager->widgets, 'sanitize_sidebar_widgets_js_instance'),
145 145
 		);
146
-		$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' );
147
-		foreach ( $default_args as $key => $default_value ) {
148
-			$this->assertEquals( $default_value, $args[ $key ] );
146
+		$args = $this->manager->widgets->get_setting_args('sidebars_widgets[sidebar-1]');
147
+		foreach ($default_args as $key => $default_value) {
148
+			$this->assertEquals($default_value, $args[$key]);
149 149
 		}
150
-		$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
150
+		$this->assertEquals('SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter']);
151 151
 
152 152
 		$override_args = array(
153 153
 			'type' => 'theme_mod',
154 154
 			'capability' => 'edit_posts',
155 155
 			'transport' => 'postMessage',
156
-			'default' => array( 'title' => 'asd' ),
156
+			'default' => array('title' => 'asd'),
157 157
 			'sanitize_callback' => '__return_empty_array',
158 158
 			'sanitize_js_callback' => '__return_empty_array',
159 159
 		);
160
-		$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-2]', $override_args );
161
-		foreach ( $override_args as $key => $override_value ) {
162
-			$this->assertEquals( $override_value, $args[ $key ] );
160
+		$args = $this->manager->widgets->get_setting_args('sidebars_widgets[sidebar-2]', $override_args);
161
+		foreach ($override_args as $key => $override_value) {
162
+			$this->assertEquals($override_value, $args[$key]);
163 163
 		}
164
-		$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );
164
+		$this->assertEquals('SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter']);
165 165
 	}
166 166
 
167
-	function filter_widget_customizer_setting_args( $args, $id ) {
168
-		$args['uppercase_id_set_by_filter'] = strtoupper( $id );
167
+	function filter_widget_customizer_setting_args($args, $id) {
168
+		$args['uppercase_id_set_by_filter'] = strtoupper($id);
169 169
 		return $args;
170 170
 	}
171 171
 
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 182
 			'dropdown' => '1',
183 183
 		);
184 184
 
185
-		$sanitized_for_js = $this->manager->widgets->sanitize_widget_js_instance( $new_categories_instance );
186
-		$this->assertArrayHasKey( 'encoded_serialized_instance', $sanitized_for_js );
187
-		$this->assertTrue( is_serialized( base64_decode( $sanitized_for_js['encoded_serialized_instance'] ), true ) );
188
-		$this->assertEquals( $new_categories_instance['title'], $sanitized_for_js['title'] );
189
-		$this->assertTrue( $sanitized_for_js['is_widget_customizer_js_value'] );
190
-		$this->assertArrayHasKey( 'instance_hash_key', $sanitized_for_js );
185
+		$sanitized_for_js = $this->manager->widgets->sanitize_widget_js_instance($new_categories_instance);
186
+		$this->assertArrayHasKey('encoded_serialized_instance', $sanitized_for_js);
187
+		$this->assertTrue(is_serialized(base64_decode($sanitized_for_js['encoded_serialized_instance']), true));
188
+		$this->assertEquals($new_categories_instance['title'], $sanitized_for_js['title']);
189
+		$this->assertTrue($sanitized_for_js['is_widget_customizer_js_value']);
190
+		$this->assertArrayHasKey('instance_hash_key', $sanitized_for_js);
191 191
 
192 192
 		$corrupted_sanitized_for_js = $sanitized_for_js;
193
-		$corrupted_sanitized_for_js['encoded_serialized_instance'] = base64_encode( serialize( array( 'title' => 'EVIL' ) ) );
194
-		$this->assertNull( $this->manager->widgets->sanitize_widget_instance( $corrupted_sanitized_for_js ), 'Expected sanitize_widget_instance to reject corrupted data.' );
193
+		$corrupted_sanitized_for_js['encoded_serialized_instance'] = base64_encode(serialize(array('title' => 'EVIL')));
194
+		$this->assertNull($this->manager->widgets->sanitize_widget_instance($corrupted_sanitized_for_js), 'Expected sanitize_widget_instance to reject corrupted data.');
195 195
 
196
-		$unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance( $sanitized_for_js );
197
-		$this->assertEquals( $unsanitized_from_js, $new_categories_instance );
196
+		$unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance($sanitized_for_js);
197
+		$this->assertEquals($unsanitized_from_js, $new_categories_instance);
198 198
 	}
199 199
 }
Please login to merge, or discard this patch.