Posts: Correctly pass $post to post_password_required() in get_the_excerpt().

Corrects the relevant test.

Props sebastian.pisula for initial patch.
Fixes #35486.

git-svn-id: https://develop.svn.wordpress.org/trunk@36329 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-01-16 10:13:27 +00:00
parent 54abada4cc
commit 3541f7b90b
2 changed files with 6 additions and 3 deletions

View File

@@ -372,7 +372,7 @@ function get_the_excerpt( $post = null ) {
return '';
}
if ( post_password_required() ) {
if ( post_password_required( $post ) ) {
return __( 'There is no excerpt because this is a protected post.' );
}

View File

@@ -199,11 +199,14 @@ EOF;
/**
* @ticket 27246
* @ticket 35486
*/
public function test_the_excerpt_password_protected_post() {
$GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
$post = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
$this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt( $post ) );
$GLOBALS['post'] = $post;
$this->assertSame( "<p>There is no excerpt because this is a protected post.</p>\n", get_echo( 'the_excerpt' ) );
$this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt() );
}
/**