Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covers g #5382

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/phpunit/tests/general/wpError.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @group general
* @group errors
*
* @covers WP_Error
* @coversDefaultClass WP_Error
*/
class Tests_General_wpError extends WP_UnitTestCase {
Expand Down
56 changes: 54 additions & 2 deletions tests/phpunit/tests/general/wpGetDocumentTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @group general
* @group template
* @group document-title
* @covers ::wp_get_document_title
* @covers ::_wp_render_title_tag
*/
class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase {

Expand Down Expand Up @@ -57,6 +55,9 @@ public function add_title_tag_support() {
add_theme_support( 'title-tag' );
}

/**
* @covers ::_wp_render_title_tag
*/
public function test__wp_render_title_tag() {
$this->go_to( '/' );

Expand All @@ -76,6 +77,9 @@ public function test__wp_render_title_tag_with_blog_description() {
_wp_render_title_tag();
}

/**
* @covers ::_wp_render_title_tag
*/
public function test__wp_render_title_no_theme_support() {
$this->go_to( '/' );

Expand All @@ -85,6 +89,9 @@ public function test__wp_render_title_no_theme_support() {
_wp_render_title_tag();
}

/**
* @covers ::wp_get_document_title
*/
public function test_short_circuiting_title() {
$this->go_to( '/' );

Expand All @@ -97,6 +104,9 @@ public function short_circuit_title( $title ) {
return 'A Wild Title';
}

/**
* @covers ::wp_get_document_title
*/
public function test_front_page_title() {
update_option( 'show_on_front', 'page' );
update_option(
Expand Down Expand Up @@ -127,6 +137,9 @@ public function front_page_title_parts( $parts ) {
return $parts;
}

/**
* @covers ::wp_get_document_title
*/
public function test_home_title() {
$blog_page_id = self::factory()->post->create(
array(
Expand All @@ -142,6 +155,9 @@ public function test_home_title() {
$this->assertSame( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_paged_title() {
$this->go_to( '?page=4' );

Expand All @@ -159,6 +175,9 @@ public function paged_title_parts( $parts ) {
return $parts;
}

/**
* @covers ::wp_get_document_title
*/
public function test_singular_title() {
$this->go_to( '?p=' . self::$post_id );

Expand All @@ -175,24 +194,36 @@ public function singular_title_parts( $parts ) {
return $parts;
}

/**
* @covers ::wp_get_document_title
*/
public function test_category_title() {
$this->go_to( '?cat=' . self::$category_id );

$this->assertSame( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_search_title() {
$this->go_to( '?s=test_title' );

$this->assertSame( sprintf( 'Search Results for “test_title” – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_author_title() {
$this->go_to( '?author=' . self::$author_id );

$this->assertSame( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_post_type_archive_title() {
register_post_type(
'cpt',
Expand All @@ -216,30 +247,45 @@ public function test_post_type_archive_title() {
$this->assertSame( sprintf( 'test_cpt – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_year_title() {
$this->go_to( '?year=2015' );

$this->assertSame( sprintf( '2015 – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_month_title() {
$this->go_to( '?monthnum=09' );

$this->assertSame( sprintf( 'September 2015 – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_day_title() {
$this->go_to( '?day=22' );

$this->assertSame( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_404_title() {
$this->go_to( '?m=404' );

$this->assertSame( sprintf( 'Page not found – %s', $this->blog_name ), wp_get_document_title() );
}

/**
* @covers ::wp_get_document_title
*/
public function test_paged_post_title() {
$this->go_to( '?paged=4&p=' . self::$post_id );

Expand All @@ -257,6 +303,9 @@ public function paged_post_title_parts( $parts ) {
return $parts;
}

/**
* @covers ::wp_get_document_title
*/
public function test_rearrange_title_parts() {
$this->go_to( '?p=' . self::$post_id );

Expand All @@ -274,6 +323,9 @@ public function rearrange_title_parts( $parts ) {
return $parts;
}

/**
* @covers ::wp_get_document_title
*/
public function test_change_title_separator() {
$this->go_to( '?p=' . self::$post_id );

Expand Down
Loading