'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'fileId' => 'wp-block-file--media-_clientId_0', 'textLinkHref' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'showDownloadButton' => true, 'displayPreview' => true, 'previewHeight' => 370, ); $content = '
yoloDownload
'; $parsed_blocks = parse_blocks( '' ); $parsed_block = $parsed_blocks[0]; $block = new WP_Block( $parsed_block ); $new_content = gutenberg_render_block_core_file( $attributes, $content, $block ); $this->assertStringContainsString( 'aria-label="Embed of yolo."', $new_content ); } /** * @covers ::render_block_core_file */ public function test_render_block_core_file_custom_filename() { $attributes = array( 'href' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'fileId' => 'wp-block-file--media-_clientId_0', 'textLinkHref' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'showDownloadButton' => true, 'displayPreview' => true, 'previewHeight' => 370, ); $content = '
custom filenameDownload
'; $parsed_blocks = parse_blocks( '' ); $parsed_block = $parsed_blocks[0]; $block = new WP_Block( $parsed_block ); $new_content = gutenberg_render_block_core_file( $attributes, $content, $block ); $this->assertStringContainsString( 'aria-label="Embed of custom filename."', $new_content ); } /** * @covers ::render_block_core_file */ public function test_render_block_core_file_formatted_filename() { $attributes = array( 'href' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'fileId' => 'wp-block-file--media-_clientId_0', 'textLinkHref' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'showDownloadButton' => true, 'displayPreview' => true, 'previewHeight' => 370, ); $content = '
Terms 2026Download
'; $parsed_blocks = parse_blocks( '' ); $parsed_block = $parsed_blocks[0]; $block = new WP_Block( $parsed_block ); $new_content = gutenberg_render_block_core_file( $attributes, $content, $block ); $this->assertStringContainsString( 'aria-label="Embed of Terms 2026."', $new_content ); } /** * @covers ::render_block_core_file */ public function test_render_block_core_file_empty_filename() { $attributes = array( 'href' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'fileId' => 'wp-block-file--media-_clientId_0', 'textLinkHref' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2021/04/yolo.pdf', 'showDownloadButton' => true, 'displayPreview' => true, 'previewHeight' => 370, ); $content = '
yoloDownload
'; $parsed_blocks = parse_blocks( '' ); $parsed_block = $parsed_blocks[0]; $block = new WP_Block( $parsed_block ); $new_content = gutenberg_render_block_core_file( $attributes, $content, $block ); $this->assertStringContainsString( 'aria-label="PDF embed"', $new_content ); } }