Make WordPress Core


Ignore:
Timestamp:
09/23/2019 09:01:16 PM (5 years ago)
Author:
kadamwhite
Message:

Posts, Post Types: Build list of "date floating" post stati dynamically when inserting post.

Completes work begun in #39953 to expose "date floating" status information to frontend clients via the REST API.

Props TimothyBlynJacobs.
Fixes #48113.

File:
1 edited

Legend:

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

    r45607 r46279  
    13951395        return 'override-slug-' . $post_type;
    13961396    }
     1397
     1398    /**
     1399     * @ticket 48113
     1400     */
     1401    public function test_insert_post_should_respect_date_floating_post_status_arg() {
     1402        register_post_status( 'floating', array( 'date_floating' => true ) );
     1403
     1404        $post_id = self::factory()->post->create(
     1405            array(
     1406                'post_status'   => 'floating',
     1407                'post_date'     => null,
     1408                'post_date_gmt' => null,
     1409            )
     1410        );
     1411
     1412        $post = get_post( $post_id );
     1413        self::assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     1414    }
     1415
     1416    /**
     1417     * @ticket 48113
     1418     */
     1419    public function test_insert_post_should_respect_date_floating_post_status_arg_not_set() {
     1420        register_post_status( 'not-floating', array( 'date_floating' => false ) );
     1421
     1422        $post_id = self::factory()->post->create(
     1423            array(
     1424                'post_status'   => 'floating',
     1425                'post_date'     => null,
     1426                'post_date_gmt' => null,
     1427            )
     1428        );
     1429
     1430        $post = get_post( $post_id );
     1431        self::assertEquals( gmdate( 'Y-m-d H:i:s' ), $post->post_date_gmt );
     1432    }
    13971433}
Note: See TracChangeset for help on using the changeset viewer.