Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
anubisthejackle committed Jan 31, 2024
1 parent 266c9d5 commit 048d7c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ public function add_no_store_to_login( $headers ): array {

return $headers;
}

}
19 changes: 14 additions & 5 deletions tests/alley/wp/alleyvate/features/test-disable-login-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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'] );
}

}

0 comments on commit 048d7c3

Please sign in to comment.