@@ -659,27 +659,42 @@ public function test_add_codemirror_adds_scripts() {
659659 $ this ->fake_current_screen ();
660660 $ this ->obj ->add_codemirror ();
661661
662- $ expected = 'jQuery\.extend\( wp\.codeEditor\.defaultSettings, {"codemirror":.+wp\.codeEditor\.initialize\( "css".+\); ' ;
662+ $ expected = 'jQuery\.extend\( wp\.codeEditor\.defaultSettings, {"codemirror": ' ;
663663
664- $ this ->expectOutputRegex ( '~ ' . $ expected . '~ims ' , wp_scripts ()->print_inline_script ( 'code-editor ' ) );
664+ if ( method_exists ( 'WP_Scripts ' , 'get_inline_script_data ' ) ) {
665+ $ this ->assertMatchesRegularExpression ( '~ ' . $ expected . '~ims ' , wp_scripts ()->get_inline_script_data ( 'code-editor ' ) );
666+ } else {
667+ // Pre WP-6.3
668+ $ this ->expectOutputRegex ( '~ ' . $ expected . '~ims ' , wp_scripts ()->print_inline_script ( 'code-editor ' ) );
669+ }
665670 }
666671
667672 public function test_add_codemirror_does_not_add_scripts_on_other_screen_ids () {
668673 $ this ->fake_current_screen ();
669674 set_current_screen ( 'another ' );
670675 $ this ->obj ->add_codemirror ();
671676
672- $ inline_script = wp_scripts ()->print_inline_script ( 'code-editor ' , 'after ' , false );
677+ if ( method_exists ( 'WP_Scripts ' , 'get_inline_script_data ' ) ) {
678+ $ inline_script = wp_scripts ()->get_inline_script_data ( 'code-editor ' );
679+ } else {
680+ // Pre WP-6.3
681+ $ inline_script = wp_scripts ()->print_inline_script ( 'code-editor ' , 'after ' , false );
682+ }
673683
674- $ this ->assertEquals ( '' , $ inline_script );
684+ $ this ->assertEmpty ( $ inline_script );
675685 }
676686
677687 public function test_add_codemirror_does_not_add_scripts_if_code_editor_not_registered () {
678688 $ this ->fake_current_screen ();
679689 wp_deregister_script ( 'code-editor ' );
680690 $ this ->obj ->add_codemirror ();
681691
682- $ inline_script = wp_scripts ()->print_inline_script ( 'code-editor ' , 'after ' , false );
692+ if ( method_exists ( 'WP_Scripts ' , 'get_inline_script_data ' ) ) {
693+ $ inline_script = wp_scripts ()->get_inline_script_data ( 'code-editor ' );
694+ } else {
695+ // Pre WP-6.3
696+ $ inline_script = wp_scripts ()->print_inline_script ( 'code-editor ' , 'after ' , false );
697+ }
683698
684699 $ this ->assertEmpty ( $ inline_script );
685700 }
0 commit comments