-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
179 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* Class TestSvg | ||
*/ | ||
class TestSvg extends TimmyUnitTestCase { | ||
/** | ||
* Tests whether we get the full src of an SVG with size full. | ||
* | ||
* @since 0.14.4 | ||
*/ | ||
public function test_get_timber_image_full_with_svg() { | ||
$attachment = $this->create_image( [ 'file' => 'sveegee.svg' ] ); | ||
$result = get_timber_image( $attachment, 'full' ); | ||
|
||
$image = ' src="' . $this->get_upload_url() . '/sveegee.svg" alt=""'; | ||
|
||
$this->assertEquals( $image, $result ); | ||
} | ||
|
||
/** | ||
* Tests whether we get the full src of an SVG with size large. | ||
* | ||
* @since 0.14.4 | ||
*/ | ||
public function test_get_timber_image_large_with_svg() { | ||
$attachment = $this->create_image( [ 'file' => 'sveegee.svg' ] ); | ||
$result = get_timber_image( $attachment, 'large' ); | ||
|
||
$image = ' src="' . $this->get_upload_url() . '/sveegee.svg" alt=""'; | ||
|
||
$this->assertEquals( $image, $result ); | ||
} | ||
|
||
public function test_svg_responsive_square() { | ||
$attachment = $this->create_image( [ 'file' => 'sveegee.svg' ] ); | ||
$result = get_timber_image_responsive( $attachment, 'large' ); | ||
|
||
$image = ' src="' . $this->get_upload_url() . '/sveegee.svg" width="1400" height="1400" loading="lazy" alt=""'; | ||
|
||
$this->assertEquals( $image, $result ); | ||
} | ||
|
||
public function test_svg_responsive_rect() { | ||
$attachment = $this->create_image( [ 'file' => 'svg-400-200.svg' ] ); | ||
$result = get_timber_image_responsive( $attachment, 'large' ); | ||
|
||
$image = ' src="' . $this->get_upload_url() . '/svg-400-200.svg" width="1400" height="700" loading="lazy" alt=""'; | ||
|
||
$this->assertEquals( $image, $result ); | ||
} | ||
|
||
public function test_svg_responsive_rect_without_viewbox() { | ||
$attachment = $this->create_image( [ 'file' => 'svg-without-viewbox.svg' ] ); | ||
$result = get_timber_image_responsive( $attachment, 'large' ); | ||
|
||
$image = ' src="' . $this->get_upload_url() . '/svg-without-viewbox.svg" loading="lazy" alt=""'; | ||
|
||
$this->assertEquals( $image, $result ); | ||
} | ||
} |