Skip to content

Commit

Permalink
Mock calls to newly introduced functions
Browse files Browse the repository at this point in the history
  • Loading branch information
diedexx committed Dec 3, 2021
1 parent cf56df4 commit 68aba31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/builders/indexable-post-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,11 @@ protected function get_number_of_pages_for_post( $post ) {
*
* @see \is_post_publicly_viewable Polyfill for WP 5.6. This function was introduced to WP core in 5.7.
*
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
* @param WP_Post $post The post.
*
* @return bool Whether the post is publicly viewable.
*/
protected function is_post_publicly_viewable( $post = null ) {
$post = \get_post( $post );

protected function is_post_publicly_viewable( $post ) {
if ( ! $post ) {
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/builders/indexable-post-builder-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ public function test_build() {
Monkey\Functions\expect( 'get_the_title' )->with( 1 )->andReturn( 'breadcrumb_title' );
Monkey\Functions\expect( 'wp_strip_all_tags' )->with( 'breadcrumb_title', true )->andReturn( 'breadcrumb_title' );

Monkey\Functions\expect( 'is_post_publicly_viewable' )->andReturn( true );
Monkey\Functions\expect( 'get_post_type' )->andReturn( 'post-type' );
Monkey\Functions\expect( 'get_post_status' )->andReturn( 'published' );
Monkey\Functions\expect( 'is_post_type_viewable' )->andReturn( true );
Monkey\Functions\expect( 'is_post_status_viewable' )->andReturn( true );

// Blog ID.
Monkey\Functions\expect( 'get_current_blog_id' )->once()->andReturn( 1 );
Expand Down

0 comments on commit 68aba31

Please sign in to comment.