Unit Tests: after [35186], "upgrade" the Canonical fixtures.

See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35191 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-10-15 05:50:40 +00:00
parent 3d7aa47df8
commit d424f690d2
4 changed files with 11 additions and 30 deletions

View File

@ -38,11 +38,7 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
*
* @since 4.1.0
*/
public static function generate_shared_fixtures() {
global $wp_rewrite;
$factory = new WP_UnitTest_Factory;
public static function generate_shared_fixtures( $factory ) {
self::$old_current_user = get_current_user_id();
self::$author_id = $factory->user->create( array( 'user_login' => 'canonical-author' ) );
@ -130,8 +126,6 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
$tag1 = $factory->term->create( array( 'name' => 'post-formats' ) );
self::$term_ids[ $tag1 ] = 'post_tag';
self::commit_transaction();
}
/**
@ -140,8 +134,6 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
* @since 4.1.0
*/
public static function delete_shared_fixtures() {
global $wp_rewrite;
if ( is_multisite() ) {
wpmu_delete_user( self::$author_id );
} else {
@ -165,8 +157,6 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
self::$comment_ids = array();
self::$term_ids = array();
self::$terms = array();
self::commit_transaction();
}
/**

View File

@ -9,11 +9,11 @@
* @group query
*/
class Tests_Canonical extends WP_Canonical_UnitTestCase {
public static function setUpBeforeClass() {
self::generate_shared_fixtures();
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function tearDownAfterClass() {
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}

View File

@ -10,11 +10,11 @@ require_once dirname( dirname( __FILE__ ) ) . '/canonical.php';
class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase {
// These test cases are run against the test handler in WP_Canonical
public static function setUpBeforeClass() {
self::generate_shared_fixtures();
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function tearDownAfterClass() {
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
@ -26,7 +26,6 @@ class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase {
$wp_rewrite->init();
$wp_rewrite->set_permalink_structure( '' );
$wp_rewrite->flush_rules();
$wp_rewrite->init();
}
/**

View File

@ -6,28 +6,20 @@
* @group query
*/
class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
public static function setUpBeforeClass() {
self::generate_shared_fixtures();
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function tearDownAfterClass() {
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
function setUp() {
parent::setUp();
global $wp_rewrite;
update_option( 'show_on_front', 'page' );
update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
$wp_rewrite->init();
$wp_rewrite->flush_rules();
}
function tearDown() {
global $wp_rewrite;
$wp_rewrite->init();
parent::tearDown();
}
/**