1111 * @covers ::wp_render_block_visibility_support
1212 */
1313class Tests_Block_Supports_Block_Visibility extends WP_UnitTestCase {
14- /**
15- * @var string|null
16- */
17- private $ test_block_name ;
1814
19- public function set_up () {
15+ private ?string $ test_block_name ;
16+
17+ public function set_up (): void {
2018 parent ::set_up ();
2119 $ this ->test_block_name = null ;
2220 }
2321
24- public function tear_down () {
25- unregister_block_type ( $ this ->test_block_name );
22+ public function tear_down (): void {
23+ if ( $ this ->test_block_name ) {
24+ unregister_block_type ( $ this ->test_block_name );
25+ }
2626 $ this ->test_block_name = null ;
2727 parent ::tear_down ();
2828 }
2929
3030 /**
3131 * Registers a new block for testing block visibility support.
3232 *
33- * @param string $block_name Name for the test block.
34- * @param array $supports Array defining block support configuration.
35- *
36- * @return WP_Block_Type The block type for the newly registered test block.
33+ * @param string $block_name Name for the test block.
34+ * @param array<string, bool> $supports Array defining block support configuration.
3735 */
38- private function register_visibility_block_with_support ( $ block_name , $ supports = array () ) {
36+ private function register_visibility_block_with_support ( string $ block_name , array $ supports = array () ): void {
3937 $ this ->test_block_name = $ block_name ;
4038 register_block_type (
4139 $ this ->test_block_name ,
@@ -51,7 +49,7 @@ private function register_visibility_block_with_support( $block_name, $supports
5149 );
5250 $ registry = WP_Block_Type_Registry::get_instance ();
5351
54- return $ registry ->get_registered ( $ this ->test_block_name );
52+ $ registry ->get_registered ( $ this ->test_block_name );
5553 }
5654
5755 /**
@@ -60,7 +58,7 @@ private function register_visibility_block_with_support( $block_name, $supports
6058 *
6159 * @ticket 64061
6260 */
63- public function test_block_visibility_support_hides_block_when_visibility_false () {
61+ public function test_block_visibility_support_hides_block_when_visibility_false (): void {
6462 $ this ->register_visibility_block_with_support (
6563 'test/visibility-block ' ,
6664 array ( 'visibility ' => true )
@@ -87,7 +85,7 @@ public function test_block_visibility_support_hides_block_when_visibility_false(
8785 *
8886 * @ticket 64061
8987 */
90- public function test_block_visibility_support_shows_block_when_support_not_opted_in () {
88+ public function test_block_visibility_support_shows_block_when_support_not_opted_in (): void {
9189 $ this ->register_visibility_block_with_support (
9290 'test/visibility-block ' ,
9391 array ( 'visibility ' => false )
@@ -108,10 +106,10 @@ public function test_block_visibility_support_shows_block_when_support_not_opted
108106 $ this ->assertSame ( $ block_content , $ result , 'Block content should remain unchanged when blockVisibility support is not opted in. ' );
109107 }
110108
111- /*
109+ /**
112110 * @ticket 64414
113111 */
114- public function test_block_visibility_support_no_visibility_attribute () {
112+ public function test_block_visibility_support_no_visibility_attribute (): void {
115113 $ this ->register_visibility_block_with_support (
116114 'test/block-visibility-none ' ,
117115 array ( 'visibility ' => true )
@@ -128,10 +126,10 @@ public function test_block_visibility_support_no_visibility_attribute() {
128126 $ this ->assertSame ( $ block_content , $ result , 'Block content should remain unchanged when no visibility attribute is present. ' );
129127 }
130128
131- /*
129+ /**
132130 * @ticket 64414
133131 */
134- public function test_block_visibility_support_generated_css_with_mobile_viewport_size () {
132+ public function test_block_visibility_support_generated_css_with_mobile_viewport_size (): void {
135133 $ this ->register_visibility_block_with_support (
136134 'test/viewport-mobile ' ,
137135 array ( 'visibility ' => true )
@@ -164,10 +162,10 @@ public function test_block_visibility_support_generated_css_with_mobile_viewport
164162 );
165163 }
166164
167- /*
165+ /**
168166 * @ticket 64414
169167 */
170- public function test_block_visibility_support_generated_css_with_tablet_viewport_size () {
168+ public function test_block_visibility_support_generated_css_with_tablet_viewport_size (): void {
171169 $ this ->register_visibility_block_with_support (
172170 'test/viewport-tablet ' ,
173171 array ( 'visibility ' => true )
@@ -205,10 +203,10 @@ public function test_block_visibility_support_generated_css_with_tablet_viewport
205203 );
206204 }
207205
208- /*
206+ /**
209207 * @ticket 64414
210208 */
211- public function test_block_visibility_support_generated_css_with_desktop_breakpoint () {
209+ public function test_block_visibility_support_generated_css_with_desktop_breakpoint (): void {
212210 $ this ->register_visibility_block_with_support (
213211 'test/viewport-desktop ' ,
214212 array ( 'visibility ' => true )
@@ -250,7 +248,7 @@ public function test_block_visibility_support_generated_css_with_desktop_breakpo
250248 * @ticket 64414
251249 * @ticket 64823
252250 */
253- public function test_block_visibility_support_generated_css_with_two_viewport_sizes () {
251+ public function test_block_visibility_support_generated_css_with_two_viewport_sizes (): void {
254252 $ this ->register_visibility_block_with_support (
255253 'test/viewport-two ' ,
256254 array ( 'visibility ' => true )
@@ -356,10 +354,10 @@ public function test_block_visibility_support_generated_css_with_all_viewport_si
356354 );
357355 }
358356
359- /*
357+ /**
360358 * @ticket 64414
361359 */
362- public function test_block_visibility_support_generated_css_with_empty_object () {
360+ public function test_block_visibility_support_generated_css_with_empty_object (): void {
363361 $ this ->register_visibility_block_with_support (
364362 'test/viewport-empty ' ,
365363 array ( 'visibility ' => true )
@@ -380,10 +378,10 @@ public function test_block_visibility_support_generated_css_with_empty_object()
380378 $ this ->assertSame ( $ block_content , $ result , 'Block content should remain unchanged when blockVisibility is an empty array. ' );
381379 }
382380
383- /*
381+ /**
384382 * @ticket 64414
385383 */
386- public function test_block_visibility_support_generated_css_with_unknown_viewport_sizes_ignored () {
384+ public function test_block_visibility_support_generated_css_with_unknown_viewport_sizes_ignored (): void {
387385 $ this ->register_visibility_block_with_support (
388386 'test/viewport-unknown-viewport-sizes ' ,
389387 array ( 'visibility ' => true )
@@ -414,10 +412,10 @@ public function test_block_visibility_support_generated_css_with_unknown_viewpor
414412 );
415413 }
416414
417- /*
415+ /**
418416 * @ticket 64414
419417 */
420- public function test_block_visibility_support_generated_css_with_empty_content () {
418+ public function test_block_visibility_support_generated_css_with_empty_content (): void {
421419 $ this ->register_visibility_block_with_support (
422420 'test/viewport-empty-content ' ,
423421 array ( 'visibility ' => true )
0 commit comments