Make WordPress Core


Ignore:
Timestamp:
10/21/2015 03:17:36 AM (11 years ago)
Author:
wonderboymusic
Message:

AJAX UNIT TESTS: Have you ever wondered why these take 600 forevers to run? They all eventually call do_action( 'admin_init' ), which has _maybe_update_core, _maybe_update_plugins, and _maybe_update_themes hooked to it. REMOVE THEM, and AJAX unit tests run like the wind. Tests_Ajax_Response is still slow.

See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/GetComments.php

    r35242 r35311  
    2020         * @var mixed
    2121         */
    22         protected $_comment_post = null;
     22        protected static $comment_post = null;
    2323
    2424        /**
    … …  
    2626         * @var mixed
    2727         */
    28         protected $_no_comment_post = null;
     28        protected static $no_comment_post = null;
    2929
    30         /**
    31          * Set up the test fixture
    32          */
    33         public function setUp() {
    34                 parent::setUp();
    35                 $post_id = self::factory()->post->create();
    36                 self::factory()->comment->create_post_comments( $post_id, 5 );
    37                 $this->_comment_post = get_post( $post_id );
     30        protected static $comment_ids = array();
    3831
    39                 $post_id = self::factory()->post->create();
    40                 $this->_no_comment_post = get_post( $post_id );
     32        public static function wpSetUpBeforeClass( $factory ) {
     33                self::$comment_post = $factory->post->create_and_get();
     34                self::$comment_ids = $factory->comment->create_post_comments( self::$comment_post->ID, 5 );
     35                self::$no_comment_post = $factory->post->create_and_get();
     36        }
    4137
    42                 unset( $GLOBALS['post_id'] );
     38        public static function wpTearDownAfterClass() {
     39                foreach ( self::$comment_ids as $comment_id ) {
     40                        wp_delete_comment( $comment_id, true );
     41                }
     42
     43                wp_delete_post( self::$comment_post->ID, true );
     44                wp_delete_post( self::$no_comment_post->ID, true );
    4345        }
    4446
    … …  
    5658                $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    5759                $_POST['action']      = 'get-comments';
    58                 $_POST['p']           = $this->_comment_post->ID;
     60                $_POST['p']           = self::$comment_post->ID;
    5961
    6062                // Make the request
    … …  
    9395                $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    9496                $_POST['action']      = 'get-comments';
    95                 $_POST['p']           = $this->_comment_post->ID;
     97                $_POST['p']           = self::$comment_post->ID;
    9698
    9799                // Make the request
    … …  
    113115                $_POST['_ajax_nonce'] = wp_create_nonce( uniqid() );
    114116                $_POST['action']      = 'get-comments';
    115                 $_POST['p']           = $this->_comment_post->ID;
     117                $_POST['p']           = self::$comment_post->ID;
    116118
    117119                // Make the request
    … …  
    153155                $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    154156                $_POST['action']      = 'get-comments';
    155                 $_POST['p']           = $this->_no_comment_post->ID;
     157                $_POST['p']           = self::$no_comment_post->ID;
    156158
    157159                // Make the request
Note: See TracChangeset for help on using the changeset viewer.