Build/Test Tools: Remove unused posts from AJAX test setUp().

Removes the creation of five posts from the AJAX test suite `setUp()` function, replacing it with a shared fixture only where required.

See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49696 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2020-11-25 04:09:41 +00:00
parent a86bedfc92
commit 95751aeec2
2 changed files with 30 additions and 6 deletions

View File

@ -149,9 +149,6 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
// Suppress warnings from "Cannot modify header information - headers already sent by".
$this->_error_level = error_reporting();
error_reporting( $this->_error_level & ~E_WARNING );
// Make some posts.
self::factory()->post->create_many( 5 );
}
/**

View File

@ -16,6 +16,36 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
*/
public $wp_customize;
/**
* Page IDs.
*
* @var int[]
*/
public static $pages;
/**
* Post IDs.
*
* @var int[]
*/
public static $posts;
/**
* Term IDs.
*
* @var int[]
*/
public static $terms;
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
// Make some post objects.
self::$posts = $factory->post->create_many( 5 );
self::$pages = $factory->post->create_many( 5, array( 'post_type' => 'page' ) );
// Some terms too.
self::$terms = $factory->term->create_many( 5 );
}
/**
* Set up the test fixture.
*/
@ -341,9 +371,6 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
'url',
);
// Create some terms and pages.
self::factory()->term->create_many( 5 );
self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) );
$auto_draft_post = $this->wp_customize->nav_menus->insert_auto_draft_post(
array(
'post_title' => 'Test Auto Draft',