Skip to content

Commit 7b6d5da

Browse files
committed
Update function name and description to emphasize impact on back/forward navigation
1 parent abfe84e commit 7b6d5da

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

plugins/performance-lab/includes/site-health/cache-control-headers/helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Helper functions used for Cache-Control headers site health check.
3+
* Helper functions used for Cache-Control headers for bfcache compatibility site health check.
44
*
55
* @package performance-lab
66
* @since n.e.x.t
@@ -11,14 +11,14 @@
1111
}
1212

1313
/**
14-
* Tests the Cache-Control headers.
14+
* Tests the Cache-Control headers for bfcache compatibility.
1515
*
1616
* @since n.e.x.t
1717
* @access private
1818
*
1919
* @return array{label: string, status: string, badge: array{label: string, color: string}, description: string, actions: string, test: string} Result.
2020
*/
21-
function perflab_cch_check_cache_control_test(): array {
21+
function perflab_cch_check_bfcache_compatibility(): array {
2222
$result = array(
2323
'label' => __( 'The Cache-Control response header for pages ensures fast back/forward navigation.', 'performance-lab' ),
2424
'status' => 'good',

plugins/performance-lab/includes/site-health/cache-control-headers/hooks.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
}
1212

1313
/**
14-
* Add the Cache-Control check to site health tests.
14+
* Add the bfcache compatibility check to site health tests.
1515
*
1616
* @since n.e.x.t
1717
* @access private
1818
*
1919
* @param array{direct: array<string, array{label: string, test: string}>} $tests Site Health Tests.
2020
* @return array{direct: array<string, array{label: string, test: string}>} Amended tests.
2121
*/
22-
function perflab_cch_add_cache_control_test( array $tests ): array {
22+
function perflab_cch_add_bfcache_compatibility_test( array $tests ): array {
2323
$tests['direct']['perflab_cch_cache_control'] = array(
2424
'label' => __( 'Cache-Control headers may prevent fast back/forward navigation', 'performance-lab' ),
25-
'test' => 'perflab_cch_check_cache_control_test',
25+
'test' => 'perflab_cch_check_bfcache_compatibility',
2626
);
2727
return $tests;
2828
}
29-
add_filter( 'site_status_tests', 'perflab_cch_add_cache_control_test' );
29+
add_filter( 'site_status_tests', 'perflab_cch_add_bfcache_compatibility_test' );

plugins/performance-lab/tests/includes/site-health/cache-control-headers/test-cache-control-headers.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Tests for cache-control headers health check.
3+
* Tests for cache-control headers for bfcache compatibility site health check.
44
*
55
* @package performance-lab
66
* @group cache-control-headers
@@ -29,55 +29,55 @@ public function setUp(): void {
2929
}
3030

3131
/**
32-
* Test that the cache-control headers test is added to the site health tests.
32+
* Test that the bfcache compatibility test is added to the site health tests.
3333
*
34-
* @covers ::perflab_cch_add_cache_control_test
34+
* @covers ::perflab_cch_add_bfcache_compatibility_test
3535
*/
36-
public function test_perflab_cch_add_cache_control_test(): void {
36+
public function test_perflab_cch_add_bfcache_compatibility_test(): void {
3737
$tests = array(
3838
'direct' => array(),
3939
);
4040

41-
$tests = perflab_cch_add_cache_control_test( $tests );
41+
$tests = perflab_cch_add_bfcache_compatibility_test( $tests );
4242
$this->assertArrayHasKey( 'perflab_cch_cache_control', $tests['direct'] );
43-
$this->assertEquals( 'Cache settings may impact site performance', $tests['direct']['perflab_cch_cache_control']['label'] );
44-
$this->assertEquals( 'perflab_cch_check_cache_control_test', $tests['direct']['perflab_cch_cache_control']['test'] );
43+
$this->assertEquals( 'Cache-Control headers may prevent fast back/forward navigation', $tests['direct']['perflab_cch_cache_control']['label'] );
44+
$this->assertEquals( 'perflab_cch_check_bfcache_compatibility', $tests['direct']['perflab_cch_cache_control']['test'] );
4545
}
4646

4747
/**
48-
* Test that the cache-control headers test is attached to the site status tests.
48+
* Test that the bfcache compatibility test is attached to the site status tests.
4949
*
50-
* @covers ::perflab_cch_add_cache_control_test
50+
* @covers ::perflab_cch_add_bfcache_compatibility_test
5151
*/
52-
public function test_perflab_cch_add_cache_control_test_is_attached_to_site_status_tests(): void {
53-
$this->assertNotFalse( has_filter( 'site_status_tests', 'perflab_cch_add_cache_control_test' ) );
52+
public function test_perflab_cch_add_bfcache_compatibility_test_is_attached(): void {
53+
$this->assertNotFalse( has_filter( 'site_status_tests', 'perflab_cch_add_bfcache_compatibility_test' ) );
5454
}
5555

5656
/**
57-
* Test that different conditional headers return the correct result.
57+
* Test that different Cache-Control headers return the correct bfcache compatibility result.
5858
*
59-
* @dataProvider data_test_cache_control_headers
60-
* @covers ::perflab_cch_check_cache_control_test
59+
* @dataProvider data_test_bfcache_compatibility
60+
* @covers ::perflab_cch_check_bfcache_compatibility
6161
*
6262
* @param array<int, mixed>|WP_Error $response The response headers.
6363
* @param string $expected_status The expected status.
6464
* @param string $expected_message The expected message.
6565
*/
66-
public function test_perflab_cch_check_cache_control_test( $response, string $expected_status, string $expected_message ): void {
66+
public function test_perflab_cch_check_bfcache_compatibility( $response, string $expected_status, string $expected_message ): void {
6767
$this->mocked_responses = array( home_url() => $response );
6868

69-
$result = perflab_cch_check_cache_control_test();
69+
$result = perflab_cch_check_bfcache_compatibility();
7070

7171
$this->assertEquals( $expected_status, $result['status'] );
7272
$this->assertStringContainsString( $expected_message, $result['description'] );
7373
}
7474

7575
/**
76-
* Data provider for test_cache_control_headers.
76+
* Data provider for bfcache compatibility tests.
7777
*
7878
* @return array<string, array<int, mixed>> Test data.
7979
*/
80-
public function data_test_cache_control_headers(): array {
80+
public function data_test_bfcache_compatibility(): array {
8181
return array(
8282
'headers_not_set' => array(
8383
$this->build_response( 200, array( 'cache-control' => '' ) ),
@@ -107,7 +107,7 @@ public function data_test_cache_control_headers(): array {
107107
'error' => array(
108108
new WP_Error( 'http_request_failed', 'HTTP request failed' ),
109109
'recommended',
110-
'There was an error while checking your site cache settings',
110+
'There was an error while checking your Cache-Control response header',
111111
),
112112
);
113113
}

0 commit comments

Comments
 (0)