Skip to content

Commit 426c143

Browse files
committed
Fix test by setting the current user properly
1 parent a322c93 commit 426c143

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/integration/notifications/test-class-yoast-notification.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
*/
1313
class Yoast_Notification_Test extends WPSEO_UnitTestCase {
1414

15+
/**
16+
* User ID.
17+
*
18+
* @var int
19+
*/
20+
private $user_id;
21+
1522
/**
1623
* Test capability filters get set.
1724
*
@@ -26,6 +33,20 @@ class Yoast_Notification_Test extends WPSEO_UnitTestCase {
2633
*/
2734
private $verify_capability_match_filter_args = [];
2835

36+
/**
37+
* Create user with proper caps.
38+
*/
39+
public function set_up() {
40+
parent::set_up();
41+
42+
$this->user_id = $this->factory->user->create();
43+
44+
$user = new WP_User( $this->user_id );
45+
$user->add_cap( 'wpseo_manage_options' );
46+
47+
wp_set_current_user( $this->user_id );
48+
}
49+
2950
/**
3051
* No ID is not persistent.
3152
*/

0 commit comments

Comments
 (0)