@@ -190,7 +190,7 @@ function test_construct_with_customize_bootstrapped() {
190
190
/**
191
191
* Tests init hooks.
192
192
*
193
- * @covers Customize_Snapshot_Manager::init()
193
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::init()
194
194
*/
195
195
public function test_init_hooks () {
196
196
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
@@ -219,8 +219,8 @@ public function test_init_hooks() {
219
219
/**
220
220
* Tests init hooks.
221
221
*
222
- * @covers Customize_Snapshot_Manager::init()
223
- * @covers Customize_Snapshot_Manager::read_current_snapshot_uuid()
222
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::init()
223
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::read_current_snapshot_uuid()
224
224
*/
225
225
public function test_read_current_snapshot_uuid () {
226
226
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
@@ -244,8 +244,8 @@ public function test_read_current_snapshot_uuid() {
244
244
/**
245
245
* Tests load_snapshot.
246
246
*
247
- * @covers Customize_Snapshot_Manager::init()
248
- * @covers Customize_Snapshot_Manager::load_snapshot()
247
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::init()
248
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::load_snapshot()
249
249
*/
250
250
public function test_load_snapshot () {
251
251
global $ wp_actions ;
@@ -272,8 +272,8 @@ public function test_load_snapshot() {
272
272
/**
273
273
* Tests setup_preview_ajax_requests.
274
274
*
275
- * @covers Customize_Snapshot_Manager::init()
276
- * @covers Customize_Snapshot_Manager::setup_preview_ajax_requests()
275
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::init()
276
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::setup_preview_ajax_requests()
277
277
*/
278
278
public function test_setup_preview_ajax_requests () {
279
279
wp_set_current_user ( $ this ->user_id );
@@ -293,7 +293,7 @@ public function test_setup_preview_ajax_requests() {
293
293
/**
294
294
* Tests override_request_method.
295
295
*
296
- * @covers Customize_Snapshot_Manager::override_request_method()
296
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::override_request_method()
297
297
*/
298
298
public function test_override_request_method () {
299
299
global $ wp ;
@@ -328,7 +328,7 @@ public function test_override_request_method() {
328
328
/**
329
329
* Tests doing_customize_save_ajax.
330
330
*
331
- * @covers Customize_Snapshot_Manager::doing_customize_save_ajax()
331
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::doing_customize_save_ajax()
332
332
*/
333
333
public function test_doing_customize_save_ajax () {
334
334
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
@@ -344,7 +344,7 @@ public function test_doing_customize_save_ajax() {
344
344
/**
345
345
* Tests ensure_customize_manager.
346
346
*
347
- * @covers Customize_Snapshot_Manager::ensure_customize_manager()
347
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::ensure_customize_manager()
348
348
*/
349
349
public function test_ensure_customize_manager () {
350
350
global $ wp_customize ;
@@ -359,7 +359,7 @@ public function test_ensure_customize_manager() {
359
359
/**
360
360
* Tests is_theme_active.
361
361
*
362
- * @covers Customize_Snapshot_Manager::is_theme_active()
362
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::is_theme_active()
363
363
*/
364
364
public function test_is_theme_active () {
365
365
global $ wp_customize ;
@@ -374,7 +374,7 @@ public function test_is_theme_active() {
374
374
/**
375
375
* Tests should_import_and_preview_snapshot.
376
376
*
377
- * @covers Customize_Snapshot_Manager::should_import_and_preview_snapshot()
377
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::should_import_and_preview_snapshot()
378
378
*/
379
379
public function test_should_import_and_preview_snapshot () {
380
380
global $ pagenow , $ wp_customize ;
@@ -431,7 +431,7 @@ public function test_should_import_and_preview_snapshot() {
431
431
/**
432
432
* Tests is_previewing_settings.
433
433
*
434
- * @covers Customize_Snapshot_Manager::is_previewing_settings()
434
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::is_previewing_settings()
435
435
*/
436
436
public function test_is_previewing_settings () {
437
437
$ _REQUEST ['customize_snapshot_uuid ' ] = self ::UUID ;
@@ -448,7 +448,7 @@ public function test_is_previewing_settings() {
448
448
/**
449
449
* Tests is_previewing_settings.
450
450
*
451
- * @covers Customize_Snapshot_Manager::is_previewing_settings()
451
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::is_previewing_settings()
452
452
*/
453
453
public function test_is_previewing_settings_via_preview_init () {
454
454
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
@@ -460,25 +460,74 @@ public function test_is_previewing_settings_via_preview_init() {
460
460
/**
461
461
* Tests preview_snapshot_settings.
462
462
*
463
- * @covers Customize_Snapshot_Manager::preview_snapshot_settings()
463
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::preview_snapshot_settings()
464
464
*/
465
465
public function test_preview_snapshot_settings () {
466
- $ this ->markTestIncomplete ();
466
+ global $ wp_actions ;
467
+ $ _REQUEST ['customize_snapshot_uuid ' ] = self ::UUID ;
468
+ $ this ->manager ->post_type ->save ( array (
469
+ 'uuid ' => self ::UUID ,
470
+ 'data ' => array (
471
+ 'blogname ' => array ( 'value ' => 'Hello ' ),
472
+ ),
473
+ 'status ' => 'draft ' ,
474
+ ) );
475
+
476
+ // Prevent init from calling preview_snapshot_settings straight away.
477
+ unset( $ wp_actions ['wp_loaded ' ] );
478
+
479
+ $ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
480
+ $ manager ->init ();
481
+ $ manager ->ensure_customize_manager ();
482
+ do_action ( 'customize_register ' , $ manager ->customize_manager );
483
+ $ this ->assertFalse ( $ manager ->is_previewing_settings () );
484
+ $ this ->assertFalse ( $ manager ->customize_manager ->get_setting ( 'blogname ' )->dirty );
485
+ $ this ->assertNotEquals ( 'Hello ' , get_option ( 'blogname ' ) );
486
+ $ manager ->preview_snapshot_settings ();
487
+ $ this ->assertEquals ( 'Hello ' , get_option ( 'blogname ' ) );
488
+ $ this ->assertTrue ( $ manager ->customize_manager ->get_setting ( 'blogname ' )->dirty );
467
489
}
468
490
469
491
/**
470
492
* Tests import_snapshot_data.
471
493
*
472
- * @covers Customize_Snapshot_Manager::import_snapshot_data()
494
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::import_snapshot_data()
473
495
*/
474
496
public function test_import_snapshot_data () {
475
- $ this ->markTestIncomplete ();
497
+ global $ wp_actions ;
498
+ $ _REQUEST ['customize_snapshot_uuid ' ] = self ::UUID ;
499
+ $ this ->manager ->post_type ->save ( array (
500
+ 'uuid ' => self ::UUID ,
501
+ 'data ' => array (
502
+ 'blogname ' => array ( 'value ' => 'Hello ' ),
503
+ 'blogdescription ' => array ( 'value ' => null ),
504
+ ),
505
+ 'status ' => 'draft ' ,
506
+ ) );
507
+
508
+ // Prevent init from calling import_snapshot_data straight away.
509
+ unset( $ wp_actions ['setup_theme ' ] );
510
+
511
+ $ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
512
+ $ manager ->init ();
513
+ $ manager ->ensure_customize_manager ();
514
+ do_action ( 'customize_register ' , $ manager ->customize_manager );
515
+
516
+ $ this ->assertArrayNotHasKey ( 'customized ' , $ _POST );
517
+ $ this ->assertArrayNotHasKey ( 'customized ' , $ _REQUEST );
518
+ $ this ->assertArrayNotHasKey ( 'blogname ' , $ manager ->customize_manager ->unsanitized_post_values () );
519
+ $ this ->assertArrayNotHasKey ( 'blogdescription ' , $ manager ->customize_manager ->unsanitized_post_values () );
520
+ $ manager ->import_snapshot_data ();
521
+ $ this ->assertArrayHasKey ( 'customized ' , $ _POST );
522
+ $ this ->assertArrayHasKey ( 'customized ' , $ _REQUEST );
523
+ $ this ->assertArrayHasKey ( 'blogname ' , $ manager ->customize_manager ->unsanitized_post_values () );
524
+ $ this ->assertArrayNotHasKey ( 'blogdescription ' , $ manager ->customize_manager ->unsanitized_post_values () );
476
525
}
477
526
478
527
/**
479
528
* Tests add_widget_setting_preview_filters.
480
529
*
481
- * @covers Customize_Snapshot_Manager::add_widget_setting_preview_filters()
530
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::add_widget_setting_preview_filters()
482
531
*/
483
532
public function test_add_widget_setting_preview_filters () {
484
533
$ this ->markTestIncomplete ();
@@ -487,7 +536,7 @@ public function test_add_widget_setting_preview_filters() {
487
536
/**
488
537
* Tests add_nav_menu_setting_preview_filters.
489
538
*
490
- * @covers Customize_Snapshot_Manager::add_nav_menu_setting_preview_filters()
539
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::add_nav_menu_setting_preview_filters()
491
540
*/
492
541
public function test_add_nav_menu_setting_preview_filters () {
493
542
$ this ->markTestIncomplete ();
@@ -496,7 +545,7 @@ public function test_add_nav_menu_setting_preview_filters() {
496
545
/**
497
546
* Tests preview_early_nav_menus_in_customizer.
498
547
*
499
- * @covers Customize_Snapshot_Manager::preview_early_nav_menus_in_customizer()
548
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::preview_early_nav_menus_in_customizer()
500
549
*/
501
550
public function test_preview_early_nav_menus_in_customizer () {
502
551
$ this ->markTestIncomplete ();
@@ -523,7 +572,7 @@ public function test_add_snapshot_uuid_to_return_url() {
523
572
/**
524
573
* Tests show_theme_switch_error.
525
574
*
526
- * @covers Customize_Snapshot_Manager::show_theme_switch_error()
575
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::show_theme_switch_error()
527
576
*/
528
577
function test_show_theme_switch_error () {
529
578
$ this ->markTestIncomplete ();
@@ -532,7 +581,7 @@ function test_show_theme_switch_error() {
532
581
/**
533
582
* Tests get_theme_switch_error.
534
583
*
535
- * @covers Customize_Snapshot_Manager::get_theme_switch_error()
584
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::get_theme_switch_error()
536
585
*/
537
586
function test_get_theme_switch_error () {
538
587
$ this ->markTestIncomplete ();
@@ -541,7 +590,7 @@ function test_get_theme_switch_error() {
541
590
/**
542
591
* Tests check_customize_publish_authorization.
543
592
*
544
- * @covers Customize_Snapshot_Manager::check_customize_publish_authorization()
593
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::check_customize_publish_authorization()
545
594
*/
546
595
function test_check_customize_publish_authorization () {
547
596
$ this ->markTestIncomplete ();
@@ -600,7 +649,7 @@ function test_enqueue_frontend_scripts() {
600
649
/**
601
650
* Test filter_customize_refresh_nonces.
602
651
*
603
- * @covers Customize_Snapshot_Manager::filter_customize_refresh_nonces()
652
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::filter_customize_refresh_nonces()
604
653
*/
605
654
function test_filter_customize_refresh_nonces () {
606
655
$ this ->markTestIncomplete ();
@@ -621,7 +670,7 @@ function test_snapshot() {
621
670
/**
622
671
* Test publish snapshot with customize_save_after.
623
672
*
624
- * @covers Customize_Snapshot_Manager::publish_snapshot_with_customize_save_after()
673
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::publish_snapshot_with_customize_save_after()
625
674
*/
626
675
function test_publish_snapshot_with_customize_save_after () {
627
676
wp_set_current_user ( $ this ->user_id );
@@ -645,7 +694,7 @@ function test_publish_snapshot_with_customize_save_after() {
645
694
/**
646
695
* Test prepare_snapshot_post_content_for_publish.
647
696
*
648
- * @covers Customize_Snapshot_Manager::prepare_snapshot_post_content_for_publish()
697
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::prepare_snapshot_post_content_for_publish()
649
698
*/
650
699
public function test_prepare_snapshot_post_content_for_publish () {
651
700
$ snapshot_manager = get_plugin_instance ()->customize_snapshot_manager ;
@@ -676,7 +725,7 @@ public function test_prepare_snapshot_post_content_for_publish() {
676
725
/**
677
726
* Test save_settings_with_publish_snapshot.
678
727
*
679
- * @covers Customize_Snapshot_Manager::save_settings_with_publish_snapshot()
728
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::save_settings_with_publish_snapshot()
680
729
*/
681
730
public function test_save_settings_with_publish_snapshot () {
682
731
$ post_type = $ this ->manager ->post_type ;
@@ -740,7 +789,7 @@ public function test_save_settings_with_publish_snapshot() {
740
789
/**
741
790
* Test prepare_errors_for_response.
742
791
*
743
- * @covers Customize_Snapshot_Manager::prepare_errors_for_response()
792
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::prepare_errors_for_response()
744
793
*/
745
794
public function test_prepare_errors_for_response () {
746
795
$ this ->markTestIncomplete ();
@@ -749,7 +798,7 @@ public function test_prepare_errors_for_response() {
749
798
/**
750
799
* Tests generate_uuid.
751
800
*
752
- * @covers Customize_Snapshot_Manager::generate_uuid()
801
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::generate_uuid()
753
802
*/
754
803
public function test_generate_uuid () {
755
804
$ this ->markTestIncomplete ();
@@ -758,7 +807,7 @@ public function test_generate_uuid() {
758
807
/**
759
808
* Tests is_valid_uuid.
760
809
*
761
- * @covers Customize_Snapshot_Manager::is_valid_uuid()
810
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::is_valid_uuid()
762
811
*/
763
812
public function test_is_valid_uuid () {
764
813
$ this ->markTestIncomplete ();
@@ -814,7 +863,7 @@ public function test_customize_menu_return() {
814
863
/**
815
864
* Tests print_admin_bar_styles.
816
865
*
817
- * @covers Customize_Snapshot_Manager::print_admin_bar_styles()
866
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::print_admin_bar_styles()
818
867
*/
819
868
public function test_print_admin_bar_styles () {
820
869
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
@@ -828,7 +877,7 @@ public function test_print_admin_bar_styles() {
828
877
/**
829
878
* Test replace_customize_link.
830
879
*
831
- * @covers Customize_Snapshot_Manager::replace_customize_link()
880
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::replace_customize_link()
832
881
*/
833
882
public function test_replace_customize_link () {
834
883
global $ wp_admin_bar ;
@@ -871,10 +920,10 @@ public function test_replace_customize_link() {
871
920
/**
872
921
* Test misc admin bar extensions.
873
922
*
874
- * @covers Customize_Snapshot_Manager::add_post_edit_screen_link()
875
- * @covers Customize_Snapshot_Manager::add_snapshot_exit_link()
876
- * @covers Customize_Snapshot_Manager::add_resume_snapshot_link()
877
- * @covers Customize_Snapshot_Manager::remove_all_non_snapshot_admin_bar_links()
923
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::add_post_edit_screen_link()
924
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::add_snapshot_exit_link()
925
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::add_resume_snapshot_link()
926
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::remove_all_non_snapshot_admin_bar_links()
878
927
*/
879
928
public function test_add_post_edit_and_exit_links () {
880
929
global $ wp_admin_bar ;
@@ -921,7 +970,7 @@ public function test_add_post_edit_and_exit_links() {
921
970
/**
922
971
* Test render templates.
923
972
*
924
- * @covers Customize_Snapshot_Manager::render_templates()
973
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::render_templates()
925
974
*/
926
975
public function test_render_templates () {
927
976
ob_start ();
@@ -940,7 +989,7 @@ public function test_render_templates() {
940
989
/**
941
990
* Test format_gmt_offset
942
991
*
943
- * @covers Customize_Snapshot_Manager::format_gmt_offset()
992
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::format_gmt_offset()
944
993
*/
945
994
public function test_format_gmt_offset () {
946
995
$ offset = $ this ->manager ->format_gmt_offset ( 7.0 );
@@ -950,7 +999,7 @@ public function test_format_gmt_offset() {
950
999
/**
951
1000
* Test month choices
952
1001
*
953
- * @covers Customize_Snapshot_Manager::get_month_choices()
1002
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::get_month_choices()
954
1003
*/
955
1004
public function test_get_month_choices () {
956
1005
$ data = $ this ->manager ->get_month_choices ();
@@ -961,7 +1010,7 @@ public function test_get_month_choices() {
961
1010
/**
962
1011
* Test override post date if empty.
963
1012
*
964
- * @covers Customize_Snapshot_Manager::override_post_date_default_data()
1013
+ * @covers CustomizeSnapshots\ Customize_Snapshot_Manager::override_post_date_default_data()
965
1014
*/
966
1015
public function test_override_post_date_default_data () {
967
1016
$ post_id = $ this ->factory ()->post ->create ();
0 commit comments