Skip to content

Commit

Permalink
fix: create guest contributors dummy emails
Browse files Browse the repository at this point in the history
  • Loading branch information
leogermani committed Jan 28, 2025
1 parent 7ef72be commit 969b1a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static function get_dummy_email_address( $user_or_name ) {
if ( is_string( $user_or_name ) ) {
return $user_or_name . '@' . $email_domain;
}
return $user->user_login . '@' . $email_domain;
return $user_or_name->user_login . '@' . $email_domain;
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/unit-tests/guest-contributor-role.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ public function set_up() { // phpcs:ignore Squiz.Commenting.FunctionComment.Miss
wp_reset_postdata();
}

/**
* On a post with author.
*/
public function test_guest_contributor_role_get_dummy_email() {
$email_domain = Guest_Contributor_Role::get_dummy_email_domain();
$user = get_userdata( 1 );

$expected = $user->user_login . '@' . $email_domain;

$dummy_email = Guest_Contributor_Role::get_dummy_email_address( $user );
$this->assertSame( $expected, $dummy_email );

$dummy_email = Guest_Contributor_Role::get_dummy_email_address( $user->user_login );
$this->assertSame( $expected, $dummy_email );
}

/**
* On a post with author.
*/
Expand Down

0 comments on commit 969b1a7

Please sign in to comment.