Skip to content

Commit a2297e0

Browse files
committed
Tests: Make block support test data providers static.
Declare the data providers in `tests/phpunit/tests/block-supports/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: #14398 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64449 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 716a329 commit a2297e0

17 files changed

Lines changed: 44 additions & 44 deletions

‎tests/phpunit/tests/block-supports/anchor.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function test_wp_apply_anchor_support( bool $support, $value, array $expe
7575
*
7676
* @return array<string, array<string, mixed>>
7777
*/
78-
public function data_wp_register_anchor_support(): array {
78+
public static function data_wp_register_anchor_support(): array {
7979
return array(
8080
'anchor attribute is registered when block supports anchor' => array(
8181
'support' => true,
@@ -130,7 +130,7 @@ public function data_wp_register_anchor_support(): array {
130130
*
131131
* @return array<string, array<string, mixed>>
132132
*/
133-
public function data_wp_apply_anchor_support(): array {
133+
public static function data_wp_apply_anchor_support(): array {
134134
return array(
135135
'anchor id attribute is applied' => array(
136136
'support' => true,

‎tests/phpunit/tests/block-supports/aria-label.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function test_wp_apply_aria_label_support( $support, $value, $expected )
7070
*
7171
* @return array
7272
*/
73-
public function data_aria_label_block_support() {
73+
public static function data_aria_label_block_support() {
7474
return array(
7575
'aria-label attribute is applied' => array(
7676
'support' => true,

‎tests/phpunit/tests/block-supports/duotone.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function test_get_slug_from_attribute( $data_attr, $expected ) {
9696
*
9797
* @return array[].
9898
*/
99-
public function data_get_slug_from_attribute() {
99+
public static function data_get_slug_from_attribute() {
100100
return array(
101101
'pipe-slug' => array( 'var:preset|duotone|blue-orange', 'blue-orange' ),
102102
'css-var' => array( 'var(--wp--preset--duotone--blue-orange)', 'blue-orange' ),
@@ -173,7 +173,7 @@ public function test_is_preset( $data_attr, $expected ) {
173173
*
174174
* @return array[].
175175
*/
176-
public function data_is_preset() {
176+
public static function data_is_preset() {
177177
return array(
178178
'pipe-slug' => array( 'var:preset|duotone|blue-orange', true ),
179179
'css-var' => array( 'var(--wp--preset--duotone--blue-orange)', true ),
@@ -203,7 +203,7 @@ public function test_colord_parse_hue( $value, $unit, $expected ) {
203203
*
204204
* @return array[].
205205
*/
206-
public function data_colord_parse_hue() {
206+
public static function data_colord_parse_hue() {
207207
return array(
208208
'deg-angle-unit' => array( 120, 'deg', 120.0 ),
209209
'grad-angle-unit' => array( 120, 'grad', 108.0 ),

‎tests/phpunit/tests/block-supports/layout.php‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function test_sanitize_block_gap_value_normalizes_zero_and_rejects_other_
111111
*
112112
* @return array[] Test data.
113113
*/
114-
public function data_sanitize_block_gap_value() {
114+
public static function data_sanitize_block_gap_value() {
115115
return array(
116116
'string value' => array( '1rem', '1rem' ),
117117
'empty string' => array( '', null ),
@@ -158,7 +158,7 @@ public function test_wp_get_layout_style( $args, $expected_output ) {
158158
*
159159
* @return array[] Test data.
160160
*/
161-
public function data_wp_get_layout_style() {
161+
public static function data_wp_get_layout_style() {
162162
return array(
163163
'flex layout uses the default for malformed gap values' => array(
164164
'args' => array(
@@ -307,7 +307,7 @@ public function test_additional_styles_moved_to_restored_outer_container_for_ali
307307
* }
308308
* }
309309
*/
310-
public function data_block_image_html_restored_outer_container() {
310+
public static function data_block_image_html_restored_outer_container() {
311311
$expected = '<div class="wp-block-image is-style-round my-custom-classname"><figure class="alignright size-full"><img src="/my-image.jpg"/></figure></div>';
312312

313313
return array(
@@ -376,7 +376,7 @@ public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $
376376
*
377377
* @return array
378378
*/
379-
public function data_layout_support_flag_renders_classnames_on_wrapper() {
379+
public static function data_layout_support_flag_renders_classnames_on_wrapper() {
380380
return array(
381381
'single wrapper block layout with flow type' => array(
382382
'args' => array(
@@ -589,7 +589,7 @@ public function test_restore_group_inner_container( $args, $expected_output ) {
589589
*
590590
* @return array
591591
*/
592-
public function data_restore_group_inner_container() {
592+
public static function data_restore_group_inner_container() {
593593
return array(
594594
'group block with existing inner container' => array(
595595
'args' => array(
@@ -684,7 +684,7 @@ public function test_wp_get_child_layout_style_rules( $child_layout, $viewport_o
684684
*
685685
* @return array
686686
*/
687-
public function data_wp_get_child_layout_style_rules() {
687+
public static function data_wp_get_child_layout_style_rules() {
688688
return array(
689689
'legacy fixed sizing remains shrinkable' => array(
690690
'child_layout' => array(
@@ -836,7 +836,7 @@ public function test_wp_add_parent_layout_to_parsed_block( $block, $parent_block
836836
*
837837
* @return array
838838
*/
839-
public function data_wp_add_parent_layout_to_parsed_block() {
839+
public static function data_wp_add_parent_layout_to_parsed_block() {
840840
return array(
841841
'block with no parent layout' => array(
842842
'block' => array(
@@ -950,7 +950,7 @@ public function test_layout_support_flag_renders_consistent_container_hash( $blo
950950
*
951951
* @return array
952952
*/
953-
public function data_layout_support_flag_renders_consistent_container_hash() {
953+
public static function data_layout_support_flag_renders_consistent_container_hash() {
954954
return array(
955955
'default type block gap 12px' => array(
956956
'block_attributes' => array(
@@ -1086,7 +1086,7 @@ public function test_layout_classname_includes_namespace_for_custom_blocks( $blo
10861086
*
10871087
* @return array
10881088
*/
1089-
public function data_layout_classname_with_custom_blocks() {
1089+
public static function data_layout_classname_with_custom_blocks() {
10901090
return array(
10911091
'custom block with constrained layout' => array(
10921092
'block_name' => 'foo/bar',
@@ -1180,7 +1180,7 @@ public function test_get_block_style_variation_name_from_registered_style( $clas
11801180
*
11811181
* @return array
11821182
*/
1183-
public function data_get_block_style_variation_name_from_registered_style() {
1183+
public static function data_get_block_style_variation_name_from_registered_style() {
11841184
return array(
11851185
'empty class name' => array(
11861186
'class_name' => '',
@@ -1589,7 +1589,7 @@ public function test_get_layout_style_with_non_numeric_grid_counts( $layout, $ex
15891589
*
15901590
* @return array
15911591
*/
1592-
public function data_get_layout_style_with_non_numeric_grid_counts() {
1592+
public static function data_get_layout_style_with_non_numeric_grid_counts() {
15931593
return array(
15941594
'non-numeric columnCount falls back to the responsive default' => array(
15951595
'layout' => array(

‎tests/phpunit/tests/block-supports/shadow.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function test_wp_apply_shadow_support( $support, $value, $expected ) {
7474
*
7575
* @return array
7676
*/
77-
public function data_generate_shadow_fixtures() {
77+
public static function data_generate_shadow_fixtures() {
7878
return array(
7979
'with no styles' => array(
8080
'support' => true,

‎tests/phpunit/tests/block-supports/typography.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public function test_wp_get_typography_font_size_value( $font_size_preset, $sett
358358
*
359359
* @return array
360360
*/
361-
public function data_generate_font_size_preset_fixtures() {
361+
public static function data_generate_font_size_preset_fixtures() {
362362
return array(
363363
'returns value when fluid typography is deactivated' => array(
364364
'font_size_preset' => array(
@@ -874,7 +874,7 @@ public function test_wp_get_typography_font_size_value_should_use_fluid_typograp
874874
*
875875
* @return array
876876
*/
877-
public function data_generate_font_size_preset_should_use_fluid_typography_deprecated_fixtures() {
877+
public static function data_generate_font_size_preset_should_use_fluid_typography_deprecated_fixtures() {
878878
return array(
879879
'returns value when fluid typography is deactivated' => array(
880880
'font_size' => array(
@@ -925,7 +925,7 @@ public function test_should_override_theme_settings( $font_size, $settings, $exp
925925
*
926926
* @return array
927927
*/
928-
public function data_generate_should_override_theme_settings_fixtures() {
928+
public static function data_generate_should_override_theme_settings_fixtures() {
929929
return array(
930930
'returns clamp value when theme activates fluid typography' => array(
931931
'font_size' => array(
@@ -1052,7 +1052,7 @@ public function test_should_covert_font_sizes_to_fluid_values( $font_size_value,
10521052
*
10531053
* @return array
10541054
*/
1055-
public function data_generate_block_supports_font_size_fixtures() {
1055+
public static function data_generate_block_supports_font_size_fixtures() {
10561056
return array(
10571057
'returns value when fluid typography is not active' => array(
10581058
'font_size_value' => '15px',
@@ -1130,7 +1130,7 @@ public function test_should_replace_inline_font_styles_with_fluid_values( $block
11301130
*
11311131
* @return array
11321132
*/
1133-
public function data_generate_replace_inline_font_styles_with_fluid_values_fixtures() {
1133+
public static function data_generate_replace_inline_font_styles_with_fluid_values_fixtures() {
11341134
return array(
11351135
'default_return_content' => array(
11361136
'block_content' => '<h2 class="has-vivid-red-background-color has-background has-link-color" style="margin-top:var(--wp--preset--spacing--60);font-size:4rem;font-style:normal;font-weight:600;letter-spacing:29px;text-decoration:underline;text-transform:capitalize">This is a heading</h2>',
@@ -1206,7 +1206,7 @@ public function test_should_add_fit_text_class_name( string $block_content, stri
12061206
*
12071207
* @return array<non-falsy-string, array{ block_content: non-falsy-string, expected_class: non-falsy-string }>
12081208
*/
1209-
public function data_should_add_fit_text_class_name(): array {
1209+
public static function data_should_add_fit_text_class_name(): array {
12101210
return array(
12111211
'wrapper without a class attribute' => array(
12121212
'block_content' => '<h1>Site Title</h1>',
@@ -1266,7 +1266,7 @@ public function test_valid_size_wp_get_typography_value_and_unit( $raw_value, $e
12661266
*
12671267
* @return array
12681268
*/
1269-
public function data_valid_size_wp_get_typography_value_and_unit() {
1269+
public static function data_valid_size_wp_get_typography_value_and_unit() {
12701270
return array(
12711271
'size: 10vh with default units do not match' => array(
12721272
'raw_value' => '10vh',
@@ -1353,7 +1353,7 @@ public function test_invalid_size_wp_get_typography_value_and_unit( $raw_value )
13531353
*
13541354
* @return array
13551355
*/
1356-
public function data_invalid_size_wp_get_typography_value_and_unit() {
1356+
public static function data_invalid_size_wp_get_typography_value_and_unit() {
13571357
return array(
13581358
'size: null' => array( null ),
13591359
'size: false' => array( false ),
@@ -1393,7 +1393,7 @@ public function test_wp_get_computed_fluid_typography_value( $args, $expected_ou
13931393
*
13941394
* @return array
13951395
*/
1396-
public function data_wp_get_computed_fluid_typography_value() {
1396+
public static function data_wp_get_computed_fluid_typography_value() {
13971397
return array(
13981398
'returns clamped value with valid args' => array(
13991399
'args' => array(

‎tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function test_minimum_height_block_support( $block_name, $dimensions, $ex
7171
*
7272
* @return array
7373
*/
74-
public function data_minimum_height_block_support() {
74+
public static function data_minimum_height_block_support() {
7575
return array(
7676
'style is applied' => array(
7777
'block_name' => 'test/dimensions-block-supports',
@@ -150,7 +150,7 @@ public function test_width_block_support( $block_name, $dimensions, $expected )
150150
*
151151
* @return array
152152
*/
153-
public function data_width_block_support() {
153+
public static function data_width_block_support() {
154154
return array(
155155
'style is applied' => array(
156156
'block_name' => 'test/width-style-is-applied',
@@ -221,7 +221,7 @@ public function test_height_block_support( $block_name, $dimensions, $expected )
221221
*
222222
* @return array
223223
*/
224-
public function data_height_block_support() {
224+
public static function data_height_block_support() {
225225
return array(
226226
'style is applied' => array(
227227
'block_name' => 'test/height-style-is-applied',
@@ -292,7 +292,7 @@ public function test_minimum_width_block_support( $block_name, $dimensions, $exp
292292
*
293293
* @return array
294294
*/
295-
public function data_minimum_width_block_support() {
295+
public static function data_minimum_width_block_support() {
296296
return array(
297297
'style is applied' => array(
298298
'block_name' => 'test/min-width-style-is-applied',

‎tests/phpunit/tests/block-supports/wpGetBlockStyleVariationNameFromClass.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function test_block_style_variation_name_extraction( $class_string, $expe
3333
*
3434
* @return array
3535
*/
36-
public function data_block_style_variation_name_extraction() {
36+
public static function data_block_style_variation_name_extraction() {
3737
return array(
3838
// @ticket 61312
3939
'missing class string' => array(

‎tests/phpunit/tests/block-supports/wpGetLayoutStyle.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function test_wp_get_layout_style( array $args, $expected_output ) {
4545
*
4646
* @return array
4747
*/
48-
public function data_wp_get_layout_style() {
48+
public static function data_wp_get_layout_style() {
4949
return array(
5050
'no args should return empty value' => array(
5151
'args' => array(),

‎tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function test_background_block_support( $theme_name, $block_name, $backgr
124124
*
125125
* @return array
126126
*/
127-
public function data_background_block_support() {
127+
public static function data_background_block_support() {
128128
return array(
129129
'background image style is applied' => array(
130130
'theme_name' => 'block-theme-child-with-fluid-typography',
@@ -312,7 +312,7 @@ public function test_background_gradient_values_pass_kses( $css ) {
312312
*
313313
* @return array[]
314314
*/
315-
public function data_background_gradient_values_pass_kses() {
315+
public static function data_background_gradient_values_pass_kses() {
316316
return array(
317317
'gradient first with rgb colors' => array(
318318
'background-image: linear-gradient(135deg, rgb(255,0,0) 0%, rgb(0,0,255) 100%), url(https://example.com/image.jpg)',

0 commit comments

Comments
 (0)