|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Tests for cache-control headers health check. |
| 3 | + * Tests for cache-control headers for bfcache compatibility site health check. |
4 | 4 | * |
5 | 5 | * @package performance-lab |
6 | 6 | * @group cache-control-headers |
@@ -29,55 +29,55 @@ public function setUp(): void { |
29 | 29 | } |
30 | 30 |
|
31 | 31 | /** |
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. |
33 | 33 | * |
34 | | - * @covers ::perflab_cch_add_cache_control_test |
| 34 | + * @covers ::perflab_cch_add_bfcache_compatibility_test |
35 | 35 | */ |
36 | | - public function test_perflab_cch_add_cache_control_test(): void { |
| 36 | + public function test_perflab_cch_add_bfcache_compatibility_test(): void { |
37 | 37 | $tests = array( |
38 | 38 | 'direct' => array(), |
39 | 39 | ); |
40 | 40 |
|
41 | | - $tests = perflab_cch_add_cache_control_test( $tests ); |
| 41 | + $tests = perflab_cch_add_bfcache_compatibility_test( $tests ); |
42 | 42 | $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'] ); |
45 | 45 | } |
46 | 46 |
|
47 | 47 | /** |
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. |
49 | 49 | * |
50 | | - * @covers ::perflab_cch_add_cache_control_test |
| 50 | + * @covers ::perflab_cch_add_bfcache_compatibility_test |
51 | 51 | */ |
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' ) ); |
54 | 54 | } |
55 | 55 |
|
56 | 56 | /** |
57 | | - * Test that different conditional headers return the correct result. |
| 57 | + * Test that different Cache-Control headers return the correct bfcache compatibility result. |
58 | 58 | * |
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 |
61 | 61 | * |
62 | 62 | * @param array<int, mixed>|WP_Error $response The response headers. |
63 | 63 | * @param string $expected_status The expected status. |
64 | 64 | * @param string $expected_message The expected message. |
65 | 65 | */ |
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 { |
67 | 67 | $this->mocked_responses = array( home_url() => $response ); |
68 | 68 |
|
69 | | - $result = perflab_cch_check_cache_control_test(); |
| 69 | + $result = perflab_cch_check_bfcache_compatibility(); |
70 | 70 |
|
71 | 71 | $this->assertEquals( $expected_status, $result['status'] ); |
72 | 72 | $this->assertStringContainsString( $expected_message, $result['description'] ); |
73 | 73 | } |
74 | 74 |
|
75 | 75 | /** |
76 | | - * Data provider for test_cache_control_headers. |
| 76 | + * Data provider for bfcache compatibility tests. |
77 | 77 | * |
78 | 78 | * @return array<string, array<int, mixed>> Test data. |
79 | 79 | */ |
80 | | - public function data_test_cache_control_headers(): array { |
| 80 | + public function data_test_bfcache_compatibility(): array { |
81 | 81 | return array( |
82 | 82 | 'headers_not_set' => array( |
83 | 83 | $this->build_response( 200, array( 'cache-control' => '' ) ), |
@@ -107,7 +107,7 @@ public function data_test_cache_control_headers(): array { |
107 | 107 | 'error' => array( |
108 | 108 | new WP_Error( 'http_request_failed', 'HTTP request failed' ), |
109 | 109 | 'recommended', |
110 | | - 'There was an error while checking your site cache settings', |
| 110 | + 'There was an error while checking your Cache-Control response header', |
111 | 111 | ), |
112 | 112 | ); |
113 | 113 | } |
|
0 commit comments