From 048d7c30c2a0dffa737491c354813f587e0fb73f Mon Sep 17 00:00:00 2001 From: Travis Weston Date: Wed, 31 Jan 2024 11:45:17 -0500 Subject: [PATCH] PHPCS --- .../features/class-disable-login-cache.php | 1 - .../features/test-disable-login-cache.php | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/alley/wp/alleyvate/features/class-disable-login-cache.php b/src/alley/wp/alleyvate/features/class-disable-login-cache.php index 561b2b25..b06ddd9c 100644 --- a/src/alley/wp/alleyvate/features/class-disable-login-cache.php +++ b/src/alley/wp/alleyvate/features/class-disable-login-cache.php @@ -48,5 +48,4 @@ public function add_no_store_to_login( $headers ): array { return $headers; } - } diff --git a/tests/alley/wp/alleyvate/features/test-disable-login-cache.php b/tests/alley/wp/alleyvate/features/test-disable-login-cache.php index 3342bb8e..d5fc8b30 100644 --- a/tests/alley/wp/alleyvate/features/test-disable-login-cache.php +++ b/tests/alley/wp/alleyvate/features/test-disable-login-cache.php @@ -37,6 +37,13 @@ protected function setUp(): void { $this->feature = new Disable_Login_Cache(); } + /** + * Verify that the no-store flag is added to the login page. + * + * Note: `wp_get_nocache_headers()` is used by `nocache_headers()` which + * in turn is called on `wp-login.php`. We call it directly here so + * we can assert against an array instead of trying to send headers. + */ public function test_login_page_cache_is_no_stored() { global $pagenow; @@ -46,10 +53,13 @@ public function test_login_page_cache_is_no_stored() { $headers = \wp_get_nocache_headers(); - self::assertArrayHasKey('Cache-Control', $headers); - self::assertStringContainsString( 'no-store', $headers['Cache-Control']); + self::assertArrayHasKey( 'Cache-Control', $headers ); + self::assertStringContainsString( 'no-store', $headers['Cache-Control'] ); } + /** + * Verify that the no-store flag isn't added to other pages. + */ public function test_non_login_page_is_stored() { global $pagenow; @@ -59,8 +69,7 @@ public function test_non_login_page_is_stored() { $headers = \wp_get_nocache_headers(); - self::assertArrayHasKey('Cache-Control', $headers); - self::assertStringNotContainsString( 'no-store', $headers['Cache-Control']); + self::assertArrayHasKey( 'Cache-Control', $headers ); + self::assertStringNotContainsString( 'no-store', $headers['Cache-Control'] ); } - }