@@ -375,6 +375,101 @@ public function test_get_files_nonexistent_theme() {
375
375
$ this ->assertEmpty ( $ files );
376
376
}
377
377
378
+ /**
379
+ * Test wp_customize_url with no $stylesheet argument.
380
+ *
381
+ * @ticket 63632
382
+ *
383
+ * @covers ::wp_customize_url
384
+ */
385
+ public function test_wp_customize_url_no_stylesheet () {
386
+ $ this ->assertSame ( esc_url ( admin_url ( 'customize.php ' ) ), wp_customize_url () );
387
+ }
388
+
389
+ /**
390
+ * Test wp_customize_url with no query args.
391
+ *
392
+ * @ticket 63632
393
+ *
394
+ * @covers ::wp_customize_url
395
+ */
396
+ public function test_wp_customize_url_without_query_args () {
397
+ $ this ->assertSame ( esc_url ( admin_url ( 'customize.php?theme=foo ' ) ), wp_customize_url ( 'foo ' ) );
398
+ }
399
+
400
+ /**
401
+ * Test wp_customize_url with existing query args.
402
+ *
403
+ * @ticket 63632
404
+ *
405
+ * @covers ::wp_customize_url
406
+ */
407
+ public function test_wp_customize_url_with_existing_query_args () {
408
+ $ clean_admin_url = admin_url ( 'customize.php ' );
409
+
410
+ // Ensure the existing query arg is present in the URL.
411
+ add_filter (
412
+ 'admin_url ' ,
413
+ function ( $ url ) {
414
+ return add_query_arg ( 'existing_arg ' , 'value ' , $ url );
415
+ }
416
+ );
417
+ $ this ->assertSame ( esc_url ( $ clean_admin_url . '?existing_arg=value&theme=foo ' ), wp_customize_url ( 'foo ' ) );
418
+ }
419
+
420
+ /**
421
+ * Test wp_customize_url with existing theme query arg.
422
+ *
423
+ * @ticket 63632
424
+ *
425
+ * @covers ::wp_customize_url
426
+ */
427
+ public function test_wp_customize_url_with_existing_theme_query_arg () {
428
+ $ clean_admin_url = admin_url ( 'customize.php ' );
429
+
430
+ // Ensure the theme query arg is replaced with the new value.
431
+ add_filter (
432
+ 'admin_url ' ,
433
+ function ( $ url ) {
434
+ return add_query_arg ( 'theme ' , 'to-be-replaced ' , $ url );
435
+ }
436
+ );
437
+ $ this ->assertSame ( esc_url ( $ clean_admin_url . '?theme=foo ' ), wp_customize_url ( 'foo ' ) );
438
+ }
439
+
440
+ /**
441
+ * Test wp_customize_url with multiple theme query args in array syntax.
442
+ *
443
+ * @ticket 63632
444
+ *
445
+ * @covers ::wp_customize_url
446
+ */
447
+ public function test_wp_customize_url_with_multiple_theme_query_args () {
448
+ $ clean_admin_url = admin_url ( 'customize.php ' );
449
+
450
+ // Ensure the theme query arg is replaced with the new value.
451
+ add_filter (
452
+ 'admin_url ' ,
453
+ function ( $ url ) {
454
+ return add_query_arg ( array ( 'theme ' => array ( 'to-be-replaced-1 ' , 'to-be-replaced-2 ' ) ), $ url );
455
+ }
456
+ );
457
+ $ this ->assertSame ( esc_url ( $ clean_admin_url . '?theme=foo ' ), wp_customize_url ( 'foo ' ) );
458
+ }
459
+
460
+ /**
461
+ * Test wp_customize_url with special characters in the theme name.
462
+ *
463
+ * @ticket 63632
464
+ *
465
+ * @covers ::wp_customize_url
466
+ */
467
+ public function test_wp_customize_url_with_special_chars () {
468
+ $ stylesheet = 'foo!@-_ + ' ;
469
+ $ expected = admin_url ( 'customize.php?theme= ' . urlencode ( $ stylesheet ) );
470
+ $ this ->assertSame ( esc_url ( $ expected ), wp_customize_url ( $ stylesheet ) );
471
+ }
472
+
378
473
/**
379
474
* Data provider.
380
475
*
0 commit comments