Make WordPress Core

Ticket #48957: test-48957.diff

File test-48957.diff, 913 bytes (added by tellyworth, 5 years ago)

Unit test to reproduce the bug

  • tests/phpunit/tests/feed/rss2.php

     
    494494                );
    495495
    496496        }
     497
     498        /**
     499         * Test get_feed_build_date() works with invalid post dates.
     500         *
     501         * @ticket 48957
     502         */
     503        public function test_function_get_feed_build_date_invalid() {
     504                $this->go_to( '/?feed=rss2' );
     505
     506                global $wp_query;
     507
     508                foreach ( array_keys( $wp_query->posts ) as $post_id ) {
     509                        // Replace post modified date with an int instead of a date string
     510                        $wp_query->posts[ $post_id ]->post_modified_gmt = 0;
     511                }
     512
     513                $build_date = get_feed_build_date( 'r' );
     514
     515                // Make sure $build_date is a valid date understood by DateTime
     516                $build_date_parsed = date_create( $build_date );
     517                $this->assertInstanceOf( DateTime::class, $build_date_parsed );
     518        }
     519
     520
    497521}