Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pls78 committed Oct 25, 2023
1 parent 33e9cf7 commit 35ad0b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion tests/unit/inc/addon-manager-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,12 @@ public function test_create_notification( $product_name, $short_link ) {
]
);

$admin_user = Mockery::mock( WP_User::class );
$admin_user->ID = 1;

Monkey\Functions\expect( 'wp_get_current_user' )
->twice();
->twice()
->andReturn( $admin_user );

Monkey\Functions\expect( 'YoastSEO' )
->once()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,10 @@ public function test_maybe_create_notification_with_indexing_failed_reason() {
->once()
->andReturn( Indexing_Reasons::REASON_INDEXING_FAILED );

$admin_user = Mockery::mock( WP_User::class );
$admin_user->ID = 1;
Monkey\Functions\expect( 'wp_get_current_user' )
->andReturn( 'user' );
->andReturn( $admin_user );

$this->notification_helper
->expects( 'restore_notification' )
Expand Down Expand Up @@ -400,8 +402,10 @@ public function test_maybe_create_notification_with_indexing_reasons( $reason )
->once()
->andReturn( $reason );

$admin_user = Mockery::mock( WP_User::class );
$admin_user->ID = 1;
Monkey\Functions\expect( 'wp_get_current_user' )
->andReturn( 'user' );
->andReturn( $admin_user );

$this->notification_helper
->expects( 'restore_notification' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public function test_notifies_when_not_installed() {
// Mock that the Yoast SEO Multilingual plugin is not installed and activated.
$this->wpml_wpseo_conditional->expects( 'is_met' )->andReturnFalse();

$admin_user = Mockery::mock( WP_User::class );
$admin_user->ID = 1;
Monkey\Functions\expect( 'wp_get_current_user' )
->andReturn( 'user' );
->andReturn( $admin_user );

$this->notification_center
->expects( 'add_notification' )
Expand Down

0 comments on commit 35ad0b5

Please sign in to comment.