Skip to content

Commit

Permalink
Use create_and_get instead of create
Browse files Browse the repository at this point in the history
  • Loading branch information
pls78 committed Oct 31, 2023
1 parent 2fa9853 commit 6220e18
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,26 +800,24 @@ public function test_add_notifications_for_multiple_users() {

$instance = $this->get_notification_center();

$user_1_id = $this->factory->user->create();
$user_1 = new WP_User( $user_1_id );
$user_1 = $this->factory->user->create_and_get();

Check failure on line 803 in tests/integration/notifications/test-class-yoast-notification-center.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned correctly; expected 1 space but found 4 spaces

Check failure on line 803 in tests/integration/notifications/test-class-yoast-notification-center.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned correctly; expected 1 space but found 4 spaces
$user_1->add_cap( 'wpseo_manage_options' );

$user_2_id = $this->factory->user->create();
$user_2 = new WP_User( $user_2_id );
$user_2 = $this->factory->user->create_and_get();

Check failure on line 806 in tests/integration/notifications/test-class-yoast-notification-center.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned correctly; expected 1 space but found 4 spaces

Check failure on line 806 in tests/integration/notifications/test-class-yoast-notification-center.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned correctly; expected 1 space but found 4 spaces
$user_2->add_cap( 'wpseo_manage_options' );

$notification_for_user_1 = new Yoast_Notification(
'Hello, user 1!',
[
'user_id' => $user_1_id,
'user_id' => $user_1->ID,
'capabilities' => [ 'wpseo_manage_options' ],
]
);

$notification_for_user_2 = new Yoast_Notification(
'Hello, user 2!',
[
'user_id' => $user_2_id,
'user_id' => $user_2->ID,
'capabilities' => [ 'wpseo_manage_options' ],
]
);
Expand All @@ -828,10 +826,10 @@ public function test_add_notifications_for_multiple_users() {
$instance->add_notification( $notification_for_user_2 );

$expected_for_user_1 = [ $notification_for_user_1 ];
$actual_for_user_1 = $instance->get_notifications_for_user( $user_1_id );
$actual_for_user_1 = $instance->get_notifications_for_user( $user_1->ID );

$expected_for_user_2 = [ $notification_for_user_2 ];
$actual_for_user_2 = $instance->get_notifications_for_user( $user_2_id );
$actual_for_user_2 = $instance->get_notifications_for_user( $user_2->ID );

$this->assertEquals( $expected_for_user_1, $actual_for_user_1 );
$this->assertEquals( $expected_for_user_2, $actual_for_user_2 );
Expand All @@ -846,15 +844,14 @@ public function test_add_notifications_only_once_for_user() {

$instance = $this->get_notification_center();

$user_id = $this->factory->user->create();
$user = new WP_User( $user_id );
$user = $this->factory->user->create_and_get();
$user->add_cap( 'wpseo_manage_options' );

$notification = new Yoast_Notification(
'Hello, user 3!',
[
'id' => 'Yoast_Notification_Test',
'user_id' => $user_id,
'user_id' => $user->ID,
'capabilities' => [ 'wpseo_manage_options' ],
]
);
Expand All @@ -863,7 +860,7 @@ public function test_add_notifications_only_once_for_user() {
$instance->add_notification( $notification );

$expected = [ $notification ];
$actual = $instance->get_notifications_for_user( $user_id );
$actual = $instance->get_notifications_for_user( $user->ID );

$this->assertEquals( $expected, $actual );
}
Expand Down

0 comments on commit 6220e18

Please sign in to comment.