Make WordPress Core

Changeset 53788


Ignore:
Timestamp:
07/27/2022 04:07:20 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Don't unnecessarily randomize the post type in some wp_insert_post() tests.

Follow-up to [33041], [52389], [53785], [53787].

See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/wpInsertPost.php

    r53787 r53788  
    689689            array(
    690690                'post_status'  => 'publish',
    691                 'post_content' => 'content',
    692                 'post_title'   => 'title',
    693691            )
    694692        );
     
    706704            array(
    707705                'post_status'  => 'publish',
    708                 'post_content' => 'content',
    709                 'post_title'   => 'title',
    710706                'post_type'    => 'page',
    711707            )
     
    721717     */
    722718    public function test_wp_insert_post_cpt_default_comment_ping_status_open() {
    723         $post_type = rand_str( 20 );
    724         register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
    725 
    726         $post_id = self::factory()->post->create(
    727             array(
    728                 'post_status'  => 'publish',
    729                 'post_content' => rand_str(),
    730                 'post_title'   => rand_str(),
    731                 'post_type'    => $post_type,
     719        register_post_type(
     720            'cpt',
     721            array(
     722                'supports' => array( 'comments', 'trackbacks' ),
     723            )
     724        );
     725
     726        $post_id = self::factory()->post->create(
     727            array(
     728                'post_status' => 'publish',
     729                'post_type'   => 'cpt',
    732730            )
    733731        );
    734732        $post    = get_post( $post_id );
    735733
    736         _unregister_post_type( $post_type );
     734        _unregister_post_type( 'cpt' );
    737735
    738736        $this->assertSame( 'open', $post->comment_status );
     
    744742     */
    745743    public function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
    746         $post_type = rand_str( 20 );
    747         register_post_type( $post_type );
    748 
    749         $post_id = self::factory()->post->create(
    750             array(
    751                 'post_status'  => 'publish',
    752                 'post_content' => rand_str(),
    753                 'post_title'   => rand_str(),
    754                 'post_type'    => $post_type,
     744        register_post_type( 'cpt' );
     745
     746        $post_id = self::factory()->post->create(
     747            array(
     748                'post_status' => 'publish',
     749                'post_type'   => 'cpt',
    755750            )
    756751        );
    757752        $post    = get_post( $post_id );
    758753
    759         _unregister_post_type( $post_type );
     754        _unregister_post_type( 'cpt' );
    760755
    761756        $this->assertSame( 'closed', $post->comment_status );
Note: See TracChangeset for help on using the changeset viewer.