'feed-with-gmt-offset.xml', 'https://example.com/testrss-dst.xml' => 'feed-across-dst.xml', ); if ( ! isset( $feeds[ $url ] ) ) { return $response; } return array( 'headers' => array( 'content-type' => 'application/rss+xml; charset=UTF-8', ), // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents 'body' => file_get_contents( GUTENBERG_DIR_TESTDATA . 'feed/' . $feeds[ $url ] ), 'response' => array( 'code' => 200, 'message' => 'OK', ), 'cookies' => array(), 'filename' => null, ); } /** * Sets up the "core/rss" block context for testing. * This is needed to avoid null access in WP_Block_Supports::apply_block_supports(). */ private function setup_block_context() { $block = array( 'blockName' => 'core/rss', 'attrs' => array(), ); $wp_block_supports = WP_Block_Supports::get_instance(); $reflection = new ReflectionClass( $wp_block_supports ); $property = $reflection->getProperty( 'block_to_render' ); if ( PHP_VERSION_ID < 80100 ) { $property->setAccessible( true ); } $property->setValue( $wp_block_supports, $block ); } /** * Test that the date in the RSS feed is correctly rendered in the HTML. * * @ticket 66970 * * @covers ::gutenberg_render_block_core_rss */ public function test_rss_date_rendering() { update_option( 'date_format', 'F j, Y' ); // We set to UTC+9 to test timezone conversion. update_option( 'gmt_offset', 9 ); $this->setup_block_context(); // Mock RSS Attributes. $attributes = array( 'feedURL' => 'https://example.com/testrss.xml', 'itemsToShow' => 2, 'displayExcerpt' => false, 'displayAuthor' => false, 'displayDate' => true, 'blockLayout' => 'list', ); $rendered_html = gutenberg_render_block_core_rss( $attributes ); $this->assertStringContainsString( '