From d424f690d2b92430f10a5b3d65dbb99b502e0050 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 Oct 2015 05:50:40 +0000 Subject: [PATCH] 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 --- tests/phpunit/includes/testcase-canonical.php | 12 +----------- tests/phpunit/tests/canonical.php | 6 +++--- tests/phpunit/tests/canonical/noRewrite.php | 7 +++---- tests/phpunit/tests/canonical/pageOnFront.php | 16 ++++------------ 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php index 4fc7565b9b..837456fb44 100644 --- a/tests/phpunit/includes/testcase-canonical.php +++ b/tests/phpunit/includes/testcase-canonical.php @@ -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(); } /** diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index 1a624a374d..1f181a0ee9 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -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(); } diff --git a/tests/phpunit/tests/canonical/noRewrite.php b/tests/phpunit/tests/canonical/noRewrite.php index 673cafe2c0..d869717b6b 100644 --- a/tests/phpunit/tests/canonical/noRewrite.php +++ b/tests/phpunit/tests/canonical/noRewrite.php @@ -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(); } /** diff --git a/tests/phpunit/tests/canonical/pageOnFront.php b/tests/phpunit/tests/canonical/pageOnFront.php index 8bfb8cefbe..a07049de3d 100644 --- a/tests/phpunit/tests/canonical/pageOnFront.php +++ b/tests/phpunit/tests/canonical/pageOnFront.php @@ -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(); } /**