Themes: Re-use fixtures in the wp_get_document_title()
tests.
See #38716 git-svn-id: https://develop.svn.wordpress.org/trunk@39172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6d98c6cda5
commit
52a834a6d8
@ -9,34 +9,39 @@
|
|||||||
class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
||||||
|
|
||||||
public $blog_name;
|
public $blog_name;
|
||||||
|
public static $category_id;
|
||||||
|
public static $author_id;
|
||||||
|
public static $post_id;
|
||||||
|
|
||||||
|
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||||
|
self::$category_id = $factory->category->create( array(
|
||||||
|
'name' => 'test_category',
|
||||||
|
) );
|
||||||
|
|
||||||
|
self::$author_id = $factory->user->create( array(
|
||||||
|
'role' => 'author',
|
||||||
|
'user_login' => 'test_author',
|
||||||
|
'description' => 'test_author',
|
||||||
|
) );
|
||||||
|
|
||||||
|
self::$post_id = $factory->post->create( array(
|
||||||
|
'post_author' => self::$author_id,
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_title' => 'test_title',
|
||||||
|
'post_type' => 'post',
|
||||||
|
'post_date' => '2015-09-22 18:52:17',
|
||||||
|
'category' => self::$category_id,
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
|
add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
|
||||||
|
|
||||||
$this->category_id = $this->factory->category->create( array(
|
|
||||||
'name' => 'test_category',
|
|
||||||
) );
|
|
||||||
|
|
||||||
$this->author_id = $this->factory->user->create( array(
|
|
||||||
'role' => 'author',
|
|
||||||
'user_login' => 'test_author',
|
|
||||||
'description' => 'test_author',
|
|
||||||
) );
|
|
||||||
|
|
||||||
$this->post_id = $this->factory->post->create( array(
|
|
||||||
'post_author' => $this->author_id,
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'post_title' => 'test_title',
|
|
||||||
'post_type' => 'post',
|
|
||||||
'post_date' => '2015-09-22 18:52:17',
|
|
||||||
'category' => $this->category_id,
|
|
||||||
) );
|
|
||||||
|
|
||||||
$this->blog_name = get_option( 'blogname' );
|
$this->blog_name = get_option( 'blogname' );
|
||||||
|
|
||||||
setup_postdata( get_post( $this->post_id ) );
|
setup_postdata( get_post( self::$post_id ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
@ -126,7 +131,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_singular_title() {
|
function test_singular_title() {
|
||||||
$this->go_to( '?p=' . $this->post_id );
|
$this->go_to( '?p=' . self::$post_id );
|
||||||
|
|
||||||
add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) );
|
add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) );
|
||||||
|
|
||||||
@ -142,7 +147,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_category_title() {
|
function test_category_title() {
|
||||||
$this->go_to( '?cat=' . $this->category_id );
|
$this->go_to( '?cat=' . self::$category_id );
|
||||||
|
|
||||||
$this->assertEquals( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() );
|
$this->assertEquals( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() );
|
||||||
}
|
}
|
||||||
@ -154,7 +159,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_author_title() {
|
function test_author_title() {
|
||||||
$this->go_to( '?author=' . $this->author_id );
|
$this->go_to( '?author=' . self::$author_id );
|
||||||
|
|
||||||
$this->assertEquals( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() );
|
$this->assertEquals( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() );
|
||||||
}
|
}
|
||||||
@ -202,7 +207,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_paged_post_title() {
|
function test_paged_post_title() {
|
||||||
$this->go_to( '?paged=4&p=' . $this->post_id );
|
$this->go_to( '?paged=4&p=' . self::$post_id );
|
||||||
|
|
||||||
add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) );
|
add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) );
|
||||||
|
|
||||||
@ -219,7 +224,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_rearrange_title_parts() {
|
function test_rearrange_title_parts() {
|
||||||
$this->go_to( '?p=' . $this->post_id );
|
$this->go_to( '?p=' . self::$post_id );
|
||||||
|
|
||||||
add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) );
|
add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) );
|
||||||
|
|
||||||
@ -236,7 +241,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_change_title_separator() {
|
function test_change_title_separator() {
|
||||||
$this->go_to( '?p=' . $this->post_id );
|
$this->go_to( '?p=' . self::$post_id );
|
||||||
|
|
||||||
add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) );
|
add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user