-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix get_image without title and description (#31)
- Loading branch information
1 parent
594b6d1
commit b819a92
Showing
2 changed files
with
76 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,11 @@ class ImageExtensionTest extends TestCase | |
*/ | ||
private $image; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
private $minimalImage; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
|
@@ -52,6 +57,19 @@ public function setUp(): void | |
], | ||
]; | ||
|
||
$this->minimalImage = [ | ||
'thumbnails' => [ | ||
'sulu-100x100' => '/uploads/media/sulu-100x100/01/image.jpg?v=1-0', | ||
'sulu-100x100.webp' => '/uploads/media/sulu-100x100/01/image.webp?v=1-0', | ||
'sulu-100x100@2x' => '/uploads/media/sulu-100x100@2x/01/image.jpg?v=1-0', | ||
'[email protected]' => '/uploads/media/sulu-100x100@2x/01/image.webp?v=1-0', | ||
'sulu-170x170' => '/uploads/media/sulu-170x170/01/image.jpg?v=1-0', | ||
'sulu-170x170.webp' => '/uploads/media/sulu-170x170/01/image.webp?v=1-0', | ||
'sulu-400x400' => '/uploads/media/sulu-400x400/01/image.jpg?v=1-0', | ||
'sulu-400x400.webp' => '/uploads/media/sulu-400x400/01/image.webp?v=1-0', | ||
], | ||
]; | ||
|
||
$this->svgImage = [ | ||
'title' => 'Title', | ||
'description' => 'Description', | ||
|
@@ -132,6 +150,29 @@ public function testPictureTag(): void | |
); | ||
} | ||
|
||
public function testPictureTagMinimalImage(): void | ||
{ | ||
$this->assertSame( | ||
'<picture>' . | ||
'<source media="(max-width: 1024px)"' . | ||
' srcset="/uploads/media/sulu-170x170/01/image.jpg?v=1-0">' . | ||
'<source media="(max-width: 650px)"' . | ||
' srcset="/uploads/media/sulu-100x100/01/image.jpg?v=1-0">' . | ||
'<img alt="image"' . | ||
' title="image"' . | ||
' src="/uploads/media/sulu-400x400/01/image.jpg?v=1-0">' . | ||
'</picture>', | ||
$this->imageExtension->getImage( | ||
$this->minimalImage, | ||
'sulu-400x400', | ||
[ | ||
'(max-width: 1024px)' => 'sulu-170x170', | ||
'(max-width: 650px)' => 'sulu-100x100', | ||
] | ||
) | ||
); | ||
} | ||
|
||
public function testComplexPictureTag(): void | ||
{ | ||
$this->assertSame( | ||
|
@@ -201,6 +242,31 @@ public function testLazyComplexImageTag(): void | |
); | ||
} | ||
|
||
public function testLazyComplexImageTagMinimalImage(): void | ||
{ | ||
$this->assertSame( | ||
'<img alt="image"' . | ||
' title="image"' . | ||
' src="/lazy/sulu-400x400.svg"' . | ||
' data-src="/uploads/media/sulu-400x400/01/image.jpg?v=1-0"' . | ||
' srcset="/lazy/sulu-400x400.svg 1024w, /lazy/sulu-170x170.svg 800w, /lazy/sulu-100x100.svg 460w"' . | ||
' data-srcset="/uploads/media/sulu-400x400/01/image.jpg?v=1-0 1024w, /uploads/media/sulu-170x170/01/image.jpg?v=1-0 800w, /uploads/media/sulu-100x100/01/image.jpg?v=1-0 460w"' . | ||
' sizes="(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw"' . | ||
' id="image-id"' . | ||
' class="image-class lazyload">', | ||
$this->imageExtension->getLazyImage( | ||
$this->minimalImage, | ||
[ | ||
'src' => 'sulu-400x400', | ||
'srcset' => 'sulu-400x400 1024w, sulu-170x170 800w, sulu-100x100 460w', | ||
'sizes' => '(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw', | ||
'id' => 'image-id', | ||
'class' => 'image-class', | ||
] | ||
) | ||
); | ||
} | ||
|
||
public function testLazyPictureTag(): void | ||
{ | ||
$this->assertSame( | ||
|