Skip to content

Commit 2181d88

Browse files
committed
Revert test changes moved to #924
1 parent 3da1363 commit 2181d88

21 files changed

Lines changed: 57 additions & 124 deletions

File tree

phpcs.xml.dist

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<config name="testVersion" value="7.0-"/>
77

88
<rule ref="WordPress-Docs"/>
9-
<rule ref="WordPress-Extra" />
9+
<rule ref="WordPress-Extra">
10+
<exclude-pattern>tests/*</exclude-pattern>
11+
</rule>
1012
<rule ref="WordPress.WP.I18n"/>
1113
<config name="text_domain" value="performance-lab,default"/>
1214

@@ -71,37 +73,5 @@
7173
<exclude-pattern>tests/utils/*</exclude-pattern>
7274
</rule>
7375

74-
<!-- Ignore inapplicable WordPress-Extra sniffs in tests. -->
75-
<rule ref="WordPress.WP.EnqueuedResourceParameters">
76-
<exclude-pattern>tests/*</exclude-pattern>
77-
</rule>
78-
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
79-
<exclude-pattern>tests/*</exclude-pattern>
80-
</rule>
81-
<rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
82-
<exclude-pattern>tests/*</exclude-pattern>
83-
</rule>
84-
<rule ref="WordPress.WP.AlternativeFunctions.unlink_unlink">
85-
<exclude-pattern>tests/*</exclude-pattern>
86-
</rule>
87-
<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
88-
<exclude-pattern>tests/*</exclude-pattern>
89-
</rule>
90-
<rule ref="WordPress.PHP.DevelopmentFunctions.error_log_var_export">
91-
<exclude-pattern>tests/*</exclude-pattern>
92-
</rule>
93-
94-
<!-- Exceptions for variable name casing. -->
95-
<rule ref="WordPress.NamingConventions.ValidVariableName">
96-
<properties>
97-
<property name="allowed_custom_properties" type="array">
98-
<element value="nodeValue"/>
99-
<element value="parentNode"/>
100-
<element value="createTextNode"/>
101-
<element value="textContent"/>
102-
</property>
103-
</properties>
104-
</rule>
105-
10676
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
10777
</ruleset>

tests/admin/load-tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function test_perflab_add_modules_page() {
8484
remove_all_filters( 'plugin_action_links_' . plugin_basename( PERFLAB_MAIN_FILE ) );
8585

8686
// Does not register the page if the perflab_active_modules filter is used.
87-
add_filter( 'perflab_active_modules', '__return_empty_array' );
87+
add_filter( 'perflab_active_modules', '__return_null' );
8888
$hook_suffix = perflab_add_modules_page();
8989
$this->assertFalse( $hook_suffix );
9090
$this->assertFalse( isset( $_wp_submenu_nopriv['options-general.php'][ PERFLAB_MODULES_SCREEN ] ) );

tests/admin/server-timing-tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function test_perflab_load_server_timing_page() {
4949
perflab_load_server_timing_page();
5050
$this->assertArrayHasKey( PERFLAB_SERVER_TIMING_SCREEN, $wp_settings_sections );
5151
$expected_sections = array( 'benchmarking' );
52-
if ( ! has_filter( 'template_include', 'ilo_buffer_output' ) ) {
52+
if ( ! has_filter( 'template_include', 'image_loading_optimization_buffer_output' ) ) {
5353
$expected_sections[] = 'output-buffering';
5454
}
5555
$this->assertEqualSets(

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
require_once $_test_root . '/includes/functions.php';
4242
tests_add_filter(
4343
'plugins_loaded',
44-
static function () {
44+
static function() {
4545
require_once TESTS_PLUGIN_DIR . '/admin/load.php';
4646
require_once TESTS_PLUGIN_DIR . '/admin/server-timing.php';
4747
$module_files = glob( TESTS_PLUGIN_DIR . '/modules/*/*/load.php' );

tests/load-tests.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public function test_perflab_get_module_settings() {
7878
$has_passed_default = false;
7979
add_filter(
8080
'default_option_' . PERFLAB_MODULES_SETTING,
81-
static function ( $current_default, $option, $passed_default ) use ( &$has_passed_default ) {
81+
static function( $default, $option, $passed_default ) use ( &$has_passed_default ) {
8282
// This callback just records whether there is a default value being passed.
8383
$has_passed_default = $passed_default;
84-
return $current_default;
84+
return $default;
8585
},
8686
10,
8787
3
@@ -134,7 +134,7 @@ public function test_perflab_get_active_modules() {
134134
$expected_active_modules = array_keys(
135135
array_filter(
136136
perflab_get_modules_setting_default(),
137-
static function ( $module_settings ) {
137+
static function( $module_settings ) {
138138
return $module_settings['enabled'];
139139
}
140140
)
@@ -158,7 +158,7 @@ public function test_perflab_get_generator_content() {
158158
array_pop( $active_modules );
159159
add_filter(
160160
'perflab_active_modules',
161-
static function () use ( $active_modules ) {
161+
static function() use ( $active_modules ) {
162162
return $active_modules;
163163
}
164164
);
@@ -229,7 +229,7 @@ private function get_expected_default_option() {
229229
$default_enabled_modules = require PERFLAB_PLUGIN_DIR_PATH . 'default-enabled-modules.php';
230230
return array_reduce(
231231
$default_enabled_modules,
232-
static function ( $module_settings, $module_dir ) {
232+
static function( $module_settings, $module_dir ) {
233233
$module_settings[ $module_dir ] = array( 'enabled' => true );
234234
return $module_settings;
235235
},
@@ -312,13 +312,13 @@ private function set_up_mock_filesystem() {
312312

313313
add_filter(
314314
'filesystem_method_file',
315-
static function () {
315+
static function() {
316316
return __DIR__ . '/utils/Filesystem/WP_Filesystem_MockFilesystem.php';
317317
}
318318
);
319319
add_filter(
320320
'filesystem_method',
321-
static function () {
321+
static function() {
322322
return 'MockFilesystem';
323323
}
324324
);

tests/modules/database/audit-autoloaded-options/audit-autoloaded-options-test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ public static function delete_autoloaded_option() {
8686
delete_option( self::AUTOLOADED_OPTION_KEY );
8787
}
8888
}
89+

tests/modules/images/dominant-color-images/dominant-color-test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function test_tag_add_adjust_to_image_attributes( $image_path, $expected_
9292

9393
$filtered_image_tags_added = dominant_color_img_tag_add_dominant_color( $filtered_image_mock_lazy_load, 'the_content', $attachment_id );
9494

95-
$this->assertStringContainsString( 'data-has-transparency="' . wp_json_encode( $expected_transparency ) . '"', $filtered_image_tags_added );
95+
$this->assertStringContainsString( 'data-has-transparency="' . json_encode( $expected_transparency ) . '"', $filtered_image_tags_added );
9696

9797
foreach ( $expected_color as $color ) {
9898
if ( false !== strpos( $color, $filtered_image_tags_added ) ) {
@@ -210,7 +210,7 @@ public function data_provider_dominant_color_check_inline_style() {
210210
public function test_dominant_color_update_attachment_image_attributes( $style_attr, $expected ) {
211211
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.jpg' );
212212

213-
$attachment_image = wp_get_attachment_image( $attachment_id, 'full', '', array( 'style' => $style_attr ) );
213+
$attachment_image = wp_get_attachment_image( $attachment_id, 'full', '', array( "style" => $style_attr ) );
214214
$this->assertStringContainsString( $expected, $attachment_image );
215215
}
216216

tests/modules/images/webp-uploads/helper-tests.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ public function it_should_return_empty_array_when_filter_returns_empty_array() {
364364
* @test
365365
*/
366366
public function it_should_return_default_transforms_when_filter_returns_non_array_type() {
367-
/** @phpstan-ignore-next-line */
368367
add_filter( 'webp_uploads_upload_image_mime_transforms', '__return_null' );
369368

370369
$default_transforms = array(
@@ -521,7 +520,7 @@ public function test_webp_uploads_in_frontend_body_within_wp_head() {
521520
$result = null;
522521
add_action(
523522
'wp_head',
524-
static function () use ( &$result ) {
523+
static function() use ( &$result ) {
525524
$result = webp_uploads_in_frontend_body();
526525
}
527526
);

tests/modules/images/webp-uploads/load-tests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public function it_should_not_replace_the_references_to_a_jpg_image_when_disable
544544

545545
add_filter(
546546
'webp_uploads_content_image_mimes',
547-
static function ( $mime_types ) {
547+
static function( $mime_types ) {
548548
unset( $mime_types[ array_search( 'image/webp', $mime_types, true ) ] );
549549
return $mime_types;
550550
}
@@ -733,7 +733,7 @@ public function it_should_prevent_replacing_an_image_uploaded_via_external_sourc
733733

734734
add_filter(
735735
'webp_uploads_pre_replace_additional_image_source',
736-
static function () {
736+
static function() {
737737
return '<img src="https://ia600200.us.archive.org/16/items/SPD-SLRSY-1867/hubblesite_2001_06.jpg">';
738738
}
739739
);
@@ -899,7 +899,7 @@ public function it_should_not_add_fallback_script_if_content_has_no_updated_imag
899899
public function it_should_create_mime_types_for_allowed_sizes_only_via_filter() {
900900
add_filter(
901901
'webp_uploads_image_sizes_with_additional_mime_type_support',
902-
static function ( $sizes ) {
902+
static function( $sizes ) {
903903
$sizes['allowed_size_400x300'] = true;
904904
return $sizes;
905905
}

tests/modules/images/webp-uploads/rest-api-tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function it_should_add_sources_to_rest_response() {
2424

2525
add_filter(
2626
'webp_uploads_upload_image_mime_transforms',
27-
static function ( $transforms ) {
27+
static function( $transforms ) {
2828
$transforms['image/jpeg'] = array( 'image/jpeg', 'image/webp' );
2929
return $transforms;
3030
}

0 commit comments

Comments
 (0)