File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,4 +110,24 @@ public function test_uppercase_extension_and_mimetype_case_insensitive()
110110 $ expected = '/home/user/PICTURE.avif ' ;
111111 $ this ->assertEquals ($ expected , Tiny_Helpers::replace_file_extension ('image/avif ' , $ input ));
112112}
113+
114+ public function test_is_pagebuilder_request_returns_false_when_no_pagebuilder_keys ()
115+ {
116+ $ _GET = array ();
117+ $ this ->assertFalse (Tiny_Helpers::is_pagebuilder_request ());
118+ }
119+
120+ public function test_is_pagebuilder_request_returns_true_for_beaver_builder ()
121+ {
122+ $ _GET = array ('fl_builder ' => '1 ' );
123+ $ this ->assertTrue (Tiny_Helpers::is_pagebuilder_request ());
124+ $ _GET = array ();
125+ }
126+
127+ public function test_is_pagebuilder_request_returns_false_for_non_pagebuilder_keys ()
128+ {
129+ $ _GET = array ('page ' => 'settings ' , 'post_id ' => '123 ' );
130+ $ this ->assertFalse (Tiny_Helpers::is_pagebuilder_request ());
131+ $ _GET = array ();
132+ }
113133}
Original file line number Diff line number Diff line change @@ -327,4 +327,30 @@ public function test_mixed_descriptors_in_source()
327327
328328 $ this ->assertSame ($ expected , $ output );
329329 }
330+
331+ public function test_does_not_register_hooks_when_pagebuilder_request ()
332+ {
333+ $ _GET = array ('fl_builder ' => '1 ' );
334+
335+ $ this ->wp ->stub ('is_admin ' , function () {
336+ return false ;
337+ });
338+
339+ $ tiny_picture = new Tiny_Picture ($ this ->vfs ->url (), array ('https://www.tinifytest.com ' ));
340+
341+ $ template_redirect_registered = false ;
342+ foreach ($ this ->wp ->getCalls ('add_action ' ) as $ call ) {
343+ if ($ call [0 ] === 'template_redirect ' ) {
344+ $ template_redirect_registered = true ;
345+ break ;
346+ }
347+ }
348+
349+ $ this ->assertFalse (
350+ $ template_redirect_registered ,
351+ 'Tiny_Picture should not register template_redirect hook when pagebuilder is active '
352+ );
353+
354+ $ _GET = array ();
355+ }
330356}
Original file line number Diff line number Diff line change @@ -469,6 +469,8 @@ public function test_conversion_enabled_but_filtered_off_not_load_picture()
469469
470470 public function test_conversion_enabled_and_not_filtered ()
471471 {
472+ $ _GET = array ();
473+
472474 // Mock settings with compression count
473475 $ mock_settings = $ this ->createMock (Tiny_Settings::class);
474476 $ mock_settings ->method ('get_conversion_enabled ' )->willReturn (true );
You can’t perform that action at this time.
0 commit comments