From 6d7c4f39f0fc0d47fed3c3bf66ef64c9feaebaa3 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 20 Mar 2015 12:34:28 +0000 Subject: [PATCH] Use shared fixtures in RSS2 unit tests. See #31705, #30017. git-svn-id: https://develop.svn.wordpress.org/trunk@31848 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/feed/rss2.php | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index 56879588a6..f8cd9cfca8 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -11,6 +11,34 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { private $permalink_structure = ''; + static $user; + static $posts; + + public static function setUpBeforeClass() { + $factory = new WP_UnitTest_Factory(); + + self::$user = $factory->user->create(); + self::$posts = $factory->post->create_many( 25, array( + 'post_author' => self::$user, + ) ); + + self::commit_transaction(); + } + + public static function tearDownAfterClass() { + if ( is_multisite() ) { + wpmu_delete_user( self::$user ); + } else { + wp_delete_user( self::$user ); + } + + foreach ( self::$posts as $post ) { + wp_delete_post( $post, true ); + } + + self::commit_transaction(); + } + public function setUp() { global $wp_rewrite; $this->permalink_structure = get_option( 'permalink_structure' ); @@ -19,11 +47,6 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { parent::setUp(); - $u = $this->factory->user->create(); - $this->factory->post->create_many( 25, array( - 'post_author' => $u, - ) ); - $this->post_count = get_option('posts_per_rss'); $this->excerpt_only = get_option('rss_use_excerpt'); // this seems to break something