Make WordPress Core


Ignore:
Timestamp:
10/22/2020 12:17:10 AM (6 years ago)
Author:
peterwilsoncc
Message:

Tests: Use shared fixtures in XML-RPC new comment unit tests.

See #51344.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/newComment.php

    r48937 r49268  
    66class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase {
    77
     8        /**
     9         * Post object for shared fixture.
     10         *
     11         * @var WP_Post
     12         */
     13        public static $post;
     14
     15        public static function wpSetUpBeforeClass( $factory ) {
     16                self::make_user_by_role( 'administrator' );
     17                self::$post = $factory->post->create_and_get();
     18        }
     19
    820        function test_valid_comment() {
    9                 $this->make_user_by_role( 'administrator' );
    10                 $post = self::factory()->post->create_and_get();
    11 
    1221                $result = $this->myxmlrpcserver->wp_newComment(
    1322                        array(
     
    1524                                'administrator',
    1625                                'administrator',
    17                                 $post->ID,
     26                                self::$post->ID,
    1827                                array(
    1928                                        'content' => rand_str( 100 ),
     
    2635
    2736        function test_empty_comment() {
    28                 $this->make_user_by_role( 'administrator' );
    29                 $post = self::factory()->post->create_and_get();
    30 
    3137                $result = $this->myxmlrpcserver->wp_newComment(
    3238                        array(
     
    3440                                'administrator',
    3541                                'administrator',
    36                                 $post->ID,
     42                                self::$post->ID,
    3743                                array(
    3844                                        'content' => '',
     
    4652
    4753        function test_new_comment_post_closed() {
    48                 $this->make_user_by_role( 'administrator' );
    4954                $post = self::factory()->post->create_and_get(
    5055                        array(
     
    7277
    7378        function test_new_comment_duplicated() {
    74                 $this->make_user_by_role( 'administrator' );
    75                 $post = self::factory()->post->create_and_get();
    76 
    7779                $comment_args = array(
    7880                        1,
    7981                        'administrator',
    8082                        'administrator',
    81                         $post->ID,
     83                        self::$post->ID,
    8284                        array(
    8385                                'content' => rand_str( 100 ),
     
    9597                $this->assertSame( 403, $result->code );
    9698        }
    97 
    9899}
Note: See TracChangeset for help on using the changeset viewer.