|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Services; |
| 4 | + |
| 5 | +use BEA\Theme\Framework\Service_Container; |
| 6 | +use BEA\Theme\Framework\Services\Svg; |
| 7 | +use WP_Mock; |
| 8 | +use WP_Mock\Tools\TestCase; |
| 9 | +use function BEA\Theme\Framework\Helpers\Formatting\Escape\escape_attribute_value; |
| 10 | +use function BEA\Theme\Framework\Helpers\Formatting\Escape\escape_content_value; |
| 11 | +use function BEA\Theme\Framework\Helpers\Formatting\Image\get_the_image; |
| 12 | +use function BEA\Theme\Framework\Helpers\Formatting\Text\get_the_text; |
| 13 | +use function BEA\Theme\Framework\Helpers\Formatting\Text\the_text; |
| 14 | +use function ob_get_clean; |
| 15 | +use function ob_start; |
| 16 | + |
| 17 | +class ImageTest extends TestCase { |
| 18 | + public function setUp(): void { |
| 19 | + WP_Mock::setUp(); |
| 20 | + } |
| 21 | + |
| 22 | + public function tearDown(): void { |
| 23 | + WP_Mock::tearDown(); |
| 24 | + } |
| 25 | + |
| 26 | + public function testGetZeroImage() { |
| 27 | + $this->assertSame( '', get_the_image( 0, [] ) ); |
| 28 | + } |
| 29 | + |
| 30 | + public function testGetImageEmpty() { |
| 31 | + WP_Mock::userFunction( 'wp_get_attachment_image', [ |
| 32 | + 'return' => '', |
| 33 | + ] |
| 34 | + ); |
| 35 | + |
| 36 | + $this->assertSame( '', get_the_image( 10, [ 'size' => '', 'data-location' => '' ] ) ); |
| 37 | + } |
| 38 | + |
| 39 | + public function testImageBeforeAfter() { |
| 40 | + WP_Mock::userFunction( 'wp_get_attachment_image', [ |
| 41 | + 'return' => '<img>', |
| 42 | + ] |
| 43 | + ); |
| 44 | + |
| 45 | + $this->assertSame( 'b<img>', get_the_image( 10, [], [ 'before' => 'b' ] ) ); |
| 46 | + $this->assertSame( '<img>a', get_the_image( 10, [], [ 'after' => 'a' ] ) ); |
| 47 | + $this->assertSame( 'b<img>a', get_the_image( 10, [], [ 'after' => 'a', 'before' => 'b' ] ) ); |
| 48 | + } |
| 49 | +} |
| 50 | + |
0 commit comments