Skip to content

Commit

Permalink
Merge pull request #205 from alleyinteractive/feature/display-name-tests
Browse files Browse the repository at this point in the history
Adding tests for the `get_the_author_display_name` functionality
  • Loading branch information
renatonascalves authored Nov 16, 2023
2 parents 1b759b8 + 6bd4cd5 commit 044ef42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion inc/core-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function auto_integrate_byline( $author_name ): string {
return get_the_byline();
}
add_filter( 'the_author', __NAMESPACE__ . '\auto_integrate_byline' );
add_filter( 'get_the_author_display_name', __NAMESPACE__ . '\auto_integrate_byline' );

/**
* Automatically integrate the byline into the `the_author_posts_link` filter.
Expand Down
18 changes: 18 additions & 0 deletions tests/feature/test-core-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,22 @@ public function test_author_link() {
get_author_posts_url( $post->post_author )
);
}

public function test_get_author_display_name_from_user(): void {
$author_name = 'Dumas Davy de la Pailleterie';
$user = static::factory()->user->create_and_get(
[
'display_name' => $author_name,
'first_name' => 'Dumas',
'last_name' => 'Davy de la Pailleterie',
]
);

static::factory()->post->create_and_get( [ 'post_author' => $user->ID ] );

$display_name = get_the_author_meta( 'display_name', $user->ID );

$this->assertNotSame( '', $display_name );
$this->assertSame( $author_name, $display_name );
}
}

0 comments on commit 044ef42

Please sign in to comment.