@@ -23,9 +23,13 @@ class Tests_HtmlApi_WpHtmlTagProcessorScriptTag extends WP_UnitTestCase {
2323 public function test_is_javascript_script_tag ( string $ html , bool $ expected_result ) {
2424 $ processor = new WP_HTML_Tag_Processor ( $ html );
2525 $ processor ->next_tag ();
26+
27+ $ result = ( function () {
28+ return $ this ->is_javascript_script_tag ();
29+ } )->call ( $ processor );
2630 $ this ->assertSame (
2731 $ expected_result ,
28- $ processor -> is_javascript_script_tag () ,
32+ $ result ,
2933 'Failed to correctly identify JavaScript script tag '
3034 );
3135 }
@@ -122,9 +126,11 @@ public static function data_is_javascript_script_tag(): array {
122126 public function test_is_javascript_script_tag_returns_false_before_finding_tags () {
123127 $ processor = new WP_HTML_Tag_Processor ( 'Just some text ' );
124128 $ processor ->next_token ();
125-
129+ $ result = ( function () {
130+ return $ this ->is_javascript_script_tag ();
131+ } )->call ( $ processor );
126132 $ this ->assertFalse (
127- $ processor -> is_javascript_script_tag () ,
133+ $ result ,
128134 'Should return false when not stopped on script tag '
129135 );
130136 }
@@ -139,8 +145,11 @@ public function test_is_javascript_script_tag_returns_false_for_non_html_namespa
139145 $ processor ->change_parsing_namespace ( 'svg ' );
140146 $ processor ->next_tag ();
141147 $ this ->assertSame ( 'SCRIPT ' , $ processor ->get_tag () );
148+ $ result = ( function () {
149+ return $ this ->is_javascript_script_tag ();
150+ } )->call ( $ processor );
142151 $ this ->assertFalse (
143- $ processor -> is_javascript_script_tag () ,
152+ $ result ,
144153 'Should return false for script tags in non-HTML namespace '
145154 );
146155 }
@@ -158,9 +167,12 @@ public function test_is_javascript_script_tag_returns_false_for_non_html_namespa
158167 public function test_is_json_script_tag ( string $ html , bool $ expected_result ) {
159168 $ processor = new WP_HTML_Tag_Processor ( $ html );
160169 $ processor ->next_tag ();
170+ $ result = ( function () {
171+ return $ this ->is_json_script_tag ();
172+ } )->call ( $ processor );
161173 $ this ->assertSame (
162174 $ expected_result ,
163- $ processor -> is_json_script_tag () ,
175+ $ result ,
164176 'Failed to correctly identify JSON script tag '
165177 );
166178 }
@@ -224,8 +236,11 @@ public static function data_is_json_script_tag(): array {
224236 public function test_is_json_script_tag_returns_false_before_finding_tags () {
225237 $ processor = new WP_HTML_Tag_Processor ( 'Just some text ' );
226238 $ processor ->next_token ();
239+ $ result = ( function () {
240+ return $ this ->is_json_script_tag ();
241+ } )->call ( $ processor );
227242 $ this ->assertFalse (
228- $ processor -> is_json_script_tag () ,
243+ $ result ,
229244 'Should return false when not stopped on script tag '
230245 );
231246 }
@@ -240,8 +255,11 @@ public function test_is_json_script_tag_returns_false_for_non_html_namespace() {
240255 $ processor ->change_parsing_namespace ( 'svg ' );
241256 $ processor ->next_tag ();
242257 $ this ->assertSame ( 'SCRIPT ' , $ processor ->get_tag () );
258+ $ result = ( function () {
259+ return $ this ->is_json_script_tag ();
260+ } )->call ( $ processor );
243261 $ this ->assertFalse (
244- $ processor -> is_json_script_tag () ,
262+ $ result ,
245263 'Should return false for script tags in non-HTML namespace '
246264 );
247265 }
0 commit comments