Make WordPress Core

Changeset 35311


Ignore:
Timestamp:
10/21/2015 03:17:36 AM (9 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.

Location:
trunk/tests/phpunit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-ajax.php

    r35242 r35311  
    2727     * @var type
    2828     */
    29     protected $_core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed_cache' );
     29    protected static $_core_actions_get = array(
     30        'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
     31        'autocomplete-user', 'dashboard-widgets', 'logged-in',
     32    );
    3033
    3134    /**
     
    3942     * @var type
    4043     */
    41     protected $_core_actions_post = array(
     44    protected static $_core_actions_post = array(
    4245        'oembed_cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
    4346        'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
     
    4851        'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
    4952        'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
    50         'wp-remove-post-lock', 'dismiss-wp-pointer', 'heartbeat', 'nopriv_heartbeat',
     53        'wp-remove-post-lock', 'dismiss-wp-pointer', 'heartbeat', 'nopriv_heartbeat', 'get-revision-diffs',
     54        'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
     55        'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post',
     56        'press-this-add-category', 'crop-image', 'generate-password',
    5157    );
     58
     59    public static function setUpBeforeClass() {
     60        if ( ! defined( 'DOING_AJAX' ) ) {
     61            define( 'DOING_AJAX', true );
     62        }
     63
     64        remove_action( 'admin_init', '_maybe_update_core' );
     65        remove_action( 'admin_init', '_maybe_update_plugins' );
     66        remove_action( 'admin_init', '_maybe_update_themes' );
     67
     68        // Register the core actions
     69        foreach ( array_merge( self::$_core_actions_get, self::$_core_actions_post ) as $action ) {
     70            if ( function_exists( 'wp_ajax_' . str_replace( '-', '_', $action ) ) ) {
     71                add_action( 'wp_ajax_' . $action, 'wp_ajax_' . str_replace( '-', '_', $action ), 1 );
     72            }
     73        }
     74
     75        parent::setUpBeforeClass();
     76    }
    5277
    5378    /**
     
    5883        parent::setUp();
    5984
    60         // Register the core actions
    61         foreach ( array_merge( $this->_core_actions_get, $this->_core_actions_post ) as $action )
    62             if ( function_exists( 'wp_ajax_' . str_replace( '-', '_', $action ) ) )
    63                 add_action( 'wp_ajax_' . $action, 'wp_ajax_' . str_replace( '-', '_', $action ), 1 );
    64 
    6585        add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
    66         if ( !defined( 'DOING_AJAX' ) )
    67             define( 'DOING_AJAX', true );
     86
    6887        set_current_screen( 'ajax' );
    6988
  • trunk/tests/phpunit/tests/ajax/Autosave.php

    r35244 r35311  
    2222    protected $_post = null;
    2323
    24     /**
    25      * user_id
    26      * @var int
    27      */
    28     protected $user_id = 0;
     24    protected static $admin_id = 0;
     25    protected static $editor_id = 0;
     26    protected static $post;
     27    protected static $post_id;
     28    protected static $user_ids = array();
     29
     30    public static function wpSetUpBeforeClass( $factory ) {
     31        self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
     32        self::$user_ids[] = self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
     33
     34        self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) );
     35        self::$post = get_post( self::$post_id );
     36    }
     37
     38    public static function wpTearDownAfterClass() {
     39        foreach ( self::$user_ids as $user_id ) {
     40            self::delete_user( $user_id );
     41        }
     42
     43        wp_delete_post( self::$post_id, true );
     44    }
    2945
    3046    /**
     
    3450        parent::setUp();
    3551        // Set a user so the $post has 'post_author'
    36         $this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    37         wp_set_current_user( $this->user_id );
    38 
    39         $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    40         $this->_post = get_post( $post_id );
     52        wp_set_current_user( self::$admin_id );
    4153    }
    4254
     
    4759    public function test_autosave_post() {
    4860        // The original post_author
    49         wp_set_current_user( $this->user_id );
     61        wp_set_current_user( self::$admin_id );
    5062
    5163        // Set up the $_POST request
     
    5668            'data' => array(
    5769                'wp_autosave' => array(
    58                     'post_id'       => $this->_post->ID,
    59                     '_wpnonce'      => wp_create_nonce( 'update-post_' . $this->_post->ID ),
    60                     'post_content'  => $this->_post->post_content . PHP_EOL . $md5,
     70                    'post_id'       => self::$post_id,
     71                    '_wpnonce'      => wp_create_nonce( 'update-post_' . self::$post->ID ),
     72                    'post_content'  => self::$post->post_content . PHP_EOL . $md5,
    6173                    'post_type'     => 'post',
    6274                ),
     
    7991
    8092        // Check that the edit happened
    81         $post = get_post( $this->_post->ID );
    82         $this->assertGreaterThanOrEqual( 0, strpos( $post->post_content, $md5 ) );
     93        $post = get_post( self::$post_id );
     94        $this->assertGreaterThanOrEqual( 0, strpos( self::$post->post_content, $md5 ) );
    8395    }
    8496
     
    89101    public function test_autosave_locked_post() {
    90102        // Lock the post to another user
    91         $another_user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    92         wp_set_current_user( $another_user_id );
    93         wp_set_post_lock( $this->_post->ID );
     103        wp_set_current_user( self::$editor_id );
     104        wp_set_post_lock( self::$post_id );
    94105
    95         wp_set_current_user( $this->user_id );
     106        wp_set_current_user( self::$admin_id );
    96107
    97108        // Ensure post is locked
    98         $this->assertEquals( $another_user_id, wp_check_post_lock( $this->_post->ID ) );
     109        $this->assertEquals( self::$editor_id, wp_check_post_lock( self::$post_id ) );
    99110
    100111        // Set up the $_POST request
     
    105116            'data' => array(
    106117                'wp_autosave' => array(
    107                     'post_id'       => $this->_post->ID,
    108                     '_wpnonce'      => wp_create_nonce( 'update-post_' . $this->_post->ID ),
    109                     'post_content'  => $this->_post->post_content . PHP_EOL . $md5,
     118                    'post_id'       => self::$post_id,
     119                    '_wpnonce'      => wp_create_nonce( 'update-post_' . self::$post_id ),
     120                    'post_content'  => self::$post->post_content . PHP_EOL . $md5,
    110121                    'post_type'     => 'post',
    111122                ),
     
    127138
    128139        // Check that the original post was NOT edited
    129         $post = get_post( $this->_post->ID );
     140        $post = get_post( self::$post_id );
    130141        $this->assertFalse( strpos( $post->post_content, $md5 ) );
    131142
    132143        // Check if the autosave post was created
    133         $autosave = wp_get_post_autosave( $this->_post->ID, get_current_user_id() );
     144        $autosave = wp_get_post_autosave( self::$post_id, get_current_user_id() );
    134145        $this->assertNotEmpty( $autosave );
    135146        $this->assertGreaterThanOrEqual( 0, strpos( $autosave->post_content, $md5 ) );
     
    142153    public function test_with_invalid_nonce( ) {
    143154
    144         wp_set_current_user( $this->user_id );
     155        wp_set_current_user( self::$admin_id );
    145156
    146157        // Set up the $_POST request
     
    150161            'data' => array(
    151162                'wp_autosave' => array(
    152                     'post_id'  => $this->_post->ID,
     163                    'post_id'  => self::$post_id,
    153164                    '_wpnonce' => substr( md5( uniqid() ), 0, 10 ),
    154165                ),
  • trunk/tests/phpunit/tests/ajax/DeleteComment.php

    r35242 r35311  
    2020     * @var array
    2121     */
    22     protected $_comments = array();
    23 
    24     /**
    25      * Set up the test fixture
    26      */
    27     public function setUp() {
    28         parent::setUp();
    29         $post_id = self::factory()->post->create();
    30         $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 );
    31         $this->_comments = array_map( 'get_comment', $this->_comments );
     22    protected static $comments = array();
     23
     24    protected static $admin_id = 0;
     25    protected static $editor_id = 0;
     26    protected static $post;
     27    protected static $post_id;
     28    protected static $user_ids = array();
     29
     30    public static function wpSetUpBeforeClass( $factory ) {
     31        self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
     32        self::$user_ids[] = self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
     33
     34        self::$post_id = $factory->post->create();
     35        self::$post = get_post( self::$post_id );
     36
     37        $comment_ids = $factory->comment->create_post_comments( self::$post_id, 8 );
     38        self::$comments = array_map( 'get_comment', $comment_ids );
     39    }
     40
     41    public static function wpTearDownAfterClass() {
     42        foreach ( self::$user_ids as $user_id ) {
     43            self::delete_user( $user_id );
     44        }
     45
     46        wp_delete_post( self::$post_id, true );
     47
     48        foreach ( self::$comments as $c ) {
     49            wp_delete_comment( $c->ID, true );
     50        }
    3251    }
    3352
     
    6786        $_POST['_ajax_nonce'] = wp_create_nonce( 'delete-comment_' . $comment->comment_ID );
    6887        $_POST[$action]       = 1;
    69         $_POST['_total']      = count( $this->_comments );
     88        $_POST['_total']      = count( self::$comments );
    7089        $_POST['_per_page']   = 100;
    7190        $_POST['_page']       = 1;
     
    125144        $_POST['_ajax_nonce'] = wp_create_nonce( 'delete-comment_' . $comment->comment_ID );
    126145        $_POST[$action]       = 1;
    127         $_POST['_total']      = count( $this->_comments );
     146        $_POST['_total']      = count( self::$comments );
    128147        $_POST['_per_page']   = 100;
    129148        $_POST['_page']       = 1;
     
    155174        $_POST['_ajax_nonce'] = wp_create_nonce( uniqid() );
    156175        $_POST[$action]       = 1;
    157         $_POST['_total']      = count( $this->_comments );
     176        $_POST['_total']      = count( self::$comments );
    158177        $_POST['_per_page']   = 100;
    159178        $_POST['_page']       = 1;
     
    184203        $_POST['_ajax_nonce'] = wp_create_nonce( 'delete-comment_12346789' );
    185204        $_POST[$action]       = 1;
    186         $_POST['_total']      = count( $this->_comments );
     205        $_POST['_total']      = count( self::$comments );
    187206        $_POST['_per_page']   = 100;
    188207        $_POST['_page']       = 1;
     
    220239        $_POST['_ajax_nonce'] = wp_create_nonce( 'delete-comment_' . $comment->comment_ID );
    221240        $_POST[$action]       = 1;
    222         $_POST['_total']      = count( $this->_comments );
     241        $_POST['_total']      = count( self::$comments );
    223242        $_POST['_per_page']   = 100;
    224243        $_POST['_page']       = 1;
     
    255274     */
    256275    public function test_ajax_comment_trash_actions_as_administrator() {
    257 
    258         // Test trash/untrash
    259         $comment = array_pop( $this->_comments );
    260         $this->_test_as_admin( $comment, 'trash' );
    261         $this->_test_as_admin( $comment, 'untrash' );
    262 
    263         // Test spam/unspam
    264         $comment = array_pop( $this->_comments );
    265         $this->_test_as_admin( $comment, 'spam' );
    266         $this->_test_as_admin( $comment, 'unspam' );
    267 
    268         // Test delete
    269         $comment = array_pop( $this->_comments );
    270         $this->_test_as_admin( $comment, 'delete' );
     276        // Test trash/untrash
     277        $this->_test_as_admin( self::$comments[0], 'trash' );
     278        $this->_test_as_admin( self::$comments[0], 'untrash' );
     279
     280        // Test spam/unspam
     281        $this->_test_as_admin( self::$comments[1], 'spam' );
     282        $this->_test_as_admin( self::$comments[1], 'unspam' );
     283
     284        // Test delete
     285        $this->_test_as_admin( self::$comments[2], 'delete' );
    271286    }
    272287
     
    276291     */
    277292    public function test_ajax_comment_trash_actions_as_subscriber() {
    278 
    279         // Test trash/untrash
    280         $comment = array_pop( $this->_comments );
    281         $this->_test_as_subscriber( $comment, 'trash' );
    282         $this->_test_as_subscriber( $comment, 'untrash' );
    283 
    284         // Test spam/unspam
    285         $comment = array_pop( $this->_comments );
    286         $this->_test_as_subscriber( $comment, 'spam' );
    287         $this->_test_as_subscriber( $comment, 'unspam' );
    288 
    289         // Test delete
    290         $comment = array_pop( $this->_comments );
    291         $this->_test_as_subscriber( $comment, 'delete' );
     293        // Test trash/untrash
     294        $this->_test_as_subscriber( self::$comments[0], 'trash' );
     295        $this->_test_as_subscriber( self::$comments[0], 'untrash' );
     296
     297        // Test spam/unspam
     298        $this->_test_as_subscriber( self::$comments[1], 'spam' );
     299        $this->_test_as_subscriber( self::$comments[1], 'unspam' );
     300
     301        // Test delete
     302        $this->_test_as_subscriber( self::$comments[2], 'delete' );
    292303    }
    293304
     
    297308     */
    298309    public function test_ajax_trash_comment_no_id() {
    299 
    300         // Test trash/untrash
    301         $comment = array_pop( $this->_comments );
    302         $this->_test_as_admin( $comment, 'trash' );
    303         $this->_test_as_admin( $comment, 'untrash' );
    304 
    305         // Test spam/unspam
    306         $comment = array_pop( $this->_comments );
    307         $this->_test_as_admin( $comment, 'spam' );
    308         $this->_test_as_admin( $comment, 'unspam' );
    309 
    310         // Test delete
    311         $comment = array_pop( $this->_comments );
    312         $this->_test_as_admin( $comment, 'delete' );
     310        // Test trash/untrash
     311        $this->_test_as_admin( self::$comments[0], 'trash' );
     312        $this->_test_as_admin( self::$comments[0], 'untrash' );
     313
     314        // Test spam/unspam
     315        $this->_test_as_admin( self::$comments[1], 'spam' );
     316        $this->_test_as_admin( self::$comments[1], 'unspam' );
     317
     318        // Test delete
     319        $this->_test_as_admin( self::$comments[2], 'delete' );
    313320    }
    314321
     
    318325     */
    319326    public function test_ajax_trash_comment_bad_nonce() {
    320 
    321         // Test trash/untrash
    322         $comment = array_pop( $this->_comments );
    323         $this->_test_with_bad_nonce( $comment, 'trash' );
    324         $this->_test_with_bad_nonce( $comment, 'untrash' );
    325 
    326         // Test spam/unspam
    327         $comment = array_pop( $this->_comments );
    328         $this->_test_with_bad_nonce( $comment, 'spam' );
    329         $this->_test_with_bad_nonce( $comment, 'unspam' );
    330 
    331         // Test delete
    332         $comment = array_pop( $this->_comments );
    333         $this->_test_with_bad_nonce( $comment, 'delete' );
     327        // Test trash/untrash
     328        $this->_test_with_bad_nonce( self::$comments[0], 'trash' );
     329        $this->_test_with_bad_nonce( self::$comments[0], 'untrash' );
     330
     331        // Test spam/unspam
     332        $this->_test_with_bad_nonce( self::$comments[1], 'spam' );
     333        $this->_test_with_bad_nonce( self::$comments[1], 'unspam' );
     334
     335        // Test delete
     336        $this->_test_with_bad_nonce( self::$comments[2], 'delete' );
    334337    }
    335338
     
    339342     */
    340343    public function test_ajax_trash_double_action() {
    341 
    342         // Test trash/untrash
    343         $comment = array_pop( $this->_comments );
    344         $this->_test_double_action( $comment, 'trash' );
    345         $this->_test_double_action( $comment, 'untrash' );
    346 
    347         // Test spam/unspam
    348         $comment = array_pop( $this->_comments );
    349         $this->_test_double_action( $comment, 'spam' );
    350         $this->_test_double_action( $comment, 'unspam' );
    351 
    352         // Test delete
    353         $comment = array_pop( $this->_comments );
    354         $this->_test_double_action( $comment, 'delete' );
     344        // Test trash/untrash
     345        $this->_test_double_action( self::$comments[0], 'trash' );
     346        $this->_test_double_action( self::$comments[0], 'untrash' );
     347
     348        // Test spam/unspam
     349        $this->_test_double_action( self::$comments[1], 'spam' );
     350        $this->_test_double_action( self::$comments[1], 'unspam' );
     351
     352        // Test delete
     353        $this->_test_double_action( self::$comments[2], 'delete' );
    355354    }
    356355}
  • 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
  • trunk/tests/phpunit/tests/ajax/ReplytoComment.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 $_draft_post = null;
    29 
    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 );
    38 
    39         $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    40         $this->_draft_post = get_post( $post_id );
     28    protected static $draft_post = null;
     29
     30    protected static $comment_ids = array();
     31
     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::$draft_post = $factory->post->create_and_get( array( 'post_status' => 'draft' ) );
     36    }
     37
     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::$draft_post->ID, true );
    4145    }
    4246
     
    5862        // Get a comment
    5963        $comments = get_comments( array(
    60             'post_id' => $this->_comment_post->ID
     64            'post_id' => self::$comment_post->ID
    6165        ) );
    6266        $comment = array_pop( $comments );
     
    6670        $_POST['comment_ID']                  = $comment->comment_ID;
    6771        $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    68         $_POST['comment_post_ID']             = $this->_comment_post->ID;
     72        $_POST['comment_post_ID']             = self::$comment_post->ID;
    6973
    7074        // Make the request
     
    102106        // Get a comment
    103107        $comments = get_comments( array(
    104         'post_id' => $this->_comment_post->ID
     108        'post_id' => self::$comment_post->ID
    105109        ) );
    106110        $comment = array_pop( $comments );
     
    110114        $_POST['comment_ID']                  = $comment->comment_ID;
    111115        $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    112         $_POST['comment_post_ID']             = $this->_comment_post->ID;
     116        $_POST['comment_post_ID']             = self::$comment_post->ID;
    113117
    114118        // Make the request
     
    129133        // Get a comment
    130134        $comments = get_comments( array(
    131             'post_id' => $this->_comment_post->ID
     135            'post_id' => self::$comment_post->ID
    132136        ) );
    133137        $comment = array_pop( $comments );
     
    137141        $_POST['comment_ID']                  = $comment->comment_ID;
    138142        $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    139         $_POST['comment_post_ID']             = $this->_comment_post->ID;
     143        $_POST['comment_post_ID']             = self::$comment_post->ID;
    140144
    141145        // Make the request
     
    177181        $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    178182        $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    179         $_POST['comment_post_ID']             = $this->_draft_post->ID;
     183        $_POST['comment_post_ID']             = self::$draft_post->ID;
    180184
    181185        // Make the request
     
    199203        $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    200204        $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    201         $_POST['comment_post_ID']             = $this->_comment_post->ID;
     205        $_POST['comment_post_ID']             = self::$comment_post->ID;
    202206
    203207        // Block comments from being saved, simulate a DB error
  • trunk/tests/phpunit/tests/ajax/TagSearch.php

    r25002 r35311  
    2020     * @var array
    2121     */
    22     private $_terms = array(
     22    private static $terms = array(
    2323        'chattels', 'depo', 'energumen', 'figuriste', 'habergeon', 'impropriation'
    2424    );
    2525
    26     /**
    27      * Setup
    28      * @todo use a term factory
    29      */
    30     public function setUp() {
    31         parent::setUp();
     26    private static $term_ids = array();
    3227
    33         foreach ( $this->_terms as $term )
    34             wp_insert_term( $term, 'post_tag' );
     28    public static function wpSetUpBeforeClass() {
     29        foreach ( self::$terms as $t ) {
     30            self::$term_ids[] = wp_insert_term( $t, 'post_tag' );
     31        }
     32    }
     33
     34    public static function wpTearDownAfterClass() {
     35        foreach ( self::$term_ids as $t ) {
     36            wp_delete_term( $t, 'post_tag' );
     37        }
    3538    }
    3639
Note: See TracChangeset for help on using the changeset viewer.