Changeset 59728 for trunk/tests/phpunit/tests/wp/sendHeaders.php
- Timestamp:
- 01/29/2025 06:10:47 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/wp/sendHeaders.php
r54710 r59728 7 7 */ 8 8 class Tests_WP_SendHeaders extends WP_UnitTestCase { 9 protected $headers_sent = array(); 9 10 10 11 /** … … 36 37 $this->go_to( get_permalink( $post_id ) ); 37 38 } 39 40 /** 41 * @ticket 61711 42 */ 43 public function test_send_headers_sets_cache_control_header_for_password_protected_posts() { 44 $password = 'password'; 45 46 add_filter( 47 'wp_headers', 48 function ( $headers ) { 49 $this->headers_sent = $headers; 50 return $headers; 51 } 52 ); 53 54 $post_id = self::factory()->post->create( 55 array( 56 'post_password' => $password, 57 ) 58 ); 59 $this->go_to( get_permalink( $post_id ) ); 60 61 $headers_without_password = $this->headers_sent; 62 $password_status_without_password = post_password_required( $post_id ); 63 64 require_once ABSPATH . WPINC . '/class-phpass.php'; 65 66 $hash = ( new PasswordHash( 8, true ) )->HashPassword( $password ); 67 68 $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] = $hash; 69 70 $this->go_to( get_permalink( $post_id ) ); 71 72 $headers_with_password = $this->headers_sent; 73 $password_status_with_password = post_password_required( $post_id ); 74 75 $this->assertTrue( $password_status_without_password ); 76 $this->assertArrayHasKey( 'Cache-Control', $headers_without_password ); 77 78 $this->assertFalse( $password_status_with_password ); 79 $this->assertArrayHasKey( 'Cache-Control', $headers_with_password ); 80 } 38 81 }
Note: See TracChangeset
for help on using the changeset viewer.