From 9dd6f369cf34c81b4417c0ed981cb4d4593a4a4f Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 30 Sep 2015 13:27:09 +0000 Subject: [PATCH] Fix db_version juggling during non-multisite tests. Continuing with the "code is poetry" theme after [34719], we need to continue to update the option in the database on non-multisite in this `wp_insert_term()` test. See #31130. git-svn-id: https://develop.svn.wordpress.org/trunk@34720 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 4 +++- tests/phpunit/tests/term/wpInsertTerm.php | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 9b33079f5f..e660e958c1 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -14,6 +14,8 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { protected static $hooks_saved = array(); protected static $ignore_files; + protected $db_version; + /** * @var WP_UnitTest_Factory */ @@ -64,8 +66,8 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { * * See #31130. */ + $this->db_version = get_option( 'db_version' ); if ( is_multisite() ) { - $this->db_version = get_option( 'db_version' ); add_filter( 'pre_option_db_version', array( $this, 'db_version' ) ); } } diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 660872c14d..09b0ea2089 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -469,8 +469,14 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { */ public function test_wp_insert_term_duplicate_slug_different_taxonomy_before_410_schema_change() { - $_db_version = $this->db_version; - $this->db_version = 30055; + // See #31130. + $old_db_version = 30055; + if ( is_multisite() ) { + $_db_version = $this->db_version; + $this->db_version = $old_db_version; + } else { + update_option( 'db_version', $old_db_version ); + } register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); @@ -497,7 +503,10 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $this->assertSame( 'foo-2', $new_term->slug ); $this->assertNotEquals( $new_term->term_id, $term->term_id ); - $this->db_version = $_db_version; + if ( is_multisite() ) { + $this->db_version = $_db_version; + } + _unregister_taxonomy( 'wptests_tax', 'post' ); }