| | 592 | |
| | 593 | /** |
| | 594 | * @ticket 44183 |
| | 595 | */ |
| | 596 | function test_get_the_archive_title_is_correct_for_author_queries() { |
| | 597 | $user_with_posts = $this->factory()->user->create_and_get( |
| | 598 | array( |
| | 599 | 'role' => 'author', |
| | 600 | ) |
| | 601 | ); |
| | 602 | $user_with_no_posts = $this->factory()->user->create_and_get( |
| | 603 | array( |
| | 604 | 'role' => 'author', |
| | 605 | ) |
| | 606 | ); |
| | 607 | |
| | 608 | $this->factory()->post->create( [ |
| | 609 | 'post_author' => $user_with_posts->ID, |
| | 610 | ] ); |
| | 611 | |
| | 612 | // Simplify the assertion by removing the default archive title prefix: |
| | 613 | add_filter( 'get_the_archive_title_prefix', '__return_empty_string' ); |
| | 614 | |
| | 615 | $this->go_to( get_author_posts_url( $user_with_posts->ID ) ); |
| | 616 | $title_when_posts = get_the_archive_title(); |
| | 617 | |
| | 618 | $this->go_to( get_author_posts_url( $user_with_no_posts->ID ) ); |
| | 619 | $title_when_no_posts = get_the_archive_title(); |
| | 620 | |
| | 621 | // Ensure the title is correct both when the user has posts and when they dont: |
| | 622 | $this->assertSame( $user_with_posts->display_name, $title_when_posts ); |
| | 623 | $this->assertSame( $user_with_no_posts->display_name, $title_when_no_posts ); |
| | 624 | } |