Skip to content

Commit

Permalink
Add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Nov 27, 2024
1 parent f196c97 commit ff14e16
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test-theme-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ public function test_make_cover_block_local() {
$this->assertStringContainsString( '/assets/images', $new_template->content );
}

public function test_make_cover_block_local_with_background_image() {
$template = new stdClass();
$template->content = '
<!-- wp:cover {"url":"http://example.com/image.jpg"} -->
<div class="wp-block-cover"><div class="wp-block-cover__image-background" style="background-image:url(http://example.com/image.jpg)"></div></div>
<!-- /wp:cover -->
';
$new_template = CBT_Theme_Media::make_template_images_local( $template );

// The image should be replaced with a relative URL
$this->assertStringNotContainsString( 'http://example.com/image.jpg', $new_template->content );
$this->assertStringContainsString( 'get_template_directory_uri', $new_template->content );
$this->assertStringContainsString( '/assets/images', $new_template->content );
}

public function test_template_with_media_correctly_prepared() {
$template = new stdClass();
$template->slug = 'test-template';
Expand Down

0 comments on commit ff14e16

Please sign in to comment.