-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use author display name as term name
- Update term name to user display name when creating terms - Sync term name when user display name is updated - Add tests
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* General user saving tests. | ||
* | ||
* @package authorship | ||
*/ | ||
|
||
declare( strict_types=1 ); | ||
|
||
namespace Authorship\Tests; | ||
|
||
use const Authorship\TAXONOMY; | ||
|
||
class TestUserDisplayName extends TestCase { | ||
public function testPostAuthorshipUpdatesTermNameWhenUserDisplayNameIsUpdated() : void { | ||
// Create an author term for the author user. | ||
$author_term = get_term_by( 'slug', (string) self::$users['author']->ID, TAXONOMY ); | ||
if ( ! $author_term ) { | ||
wp_insert_term( self::$users['author']->ID, TAXONOMY ); | ||
$author_term = get_term_by( 'slug', (string) self::$users['author']->ID, TAXONOMY ); | ||
} | ||
|
||
$display_name = 'New Author Name'; | ||
|
||
wp_update_user( [ | ||
'ID' => self::$users['author']->ID, | ||
'display_name' => $display_name, | ||
] ); | ||
|
||
$author_term = get_term_by( 'slug', (string) self::$users['author']->ID, TAXONOMY ); | ||
|
||
$this->assertSame( $display_name, $author_term->name ); | ||
} | ||
} |