Skip to content

Commit 97b6b50

Browse files
committed
Cover changes with integration tests
1 parent eaaea72 commit 97b6b50

File tree

1 file changed

+52
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images

1 file changed

+52
-0
lines changed

dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,58 @@ public function testGetThumbnailUrl(string $directory, string $filename, string
295295
$this->storage->deleteFile($path);
296296
}
297297

298+
/**
299+
* Verify thumbnail generation for diferent sizes
300+
*
301+
* @param array $sizes
302+
* @param bool $resized
303+
* @dataProvider getThumbnailsSizes
304+
*/
305+
public function testResizeFile(array $sizes, bool $resized): void
306+
{
307+
$root = $this->storage->getCmsWysiwygImages()->getStorageRoot();
308+
$path = $root . '/' . 'testfile.png';
309+
$this->generateImage($path, $sizes['width'], $sizes['height']);
310+
$this->storage->resizeFile($path);
311+
312+
$thumbPath = $this->storage->getThumbnailPath($path);
313+
list($imageWidth, $imageHeight) = getimagesize($thumbPath);
314+
315+
$this->assertEquals(
316+
$resized ? $this->storage->getResizeWidth() : $sizes['width'],
317+
$imageWidth
318+
);
319+
$this->assertLessThanOrEqual(
320+
$resized ? $this->storage->getResizeHeight() : $sizes['height'],
321+
$imageHeight
322+
);
323+
324+
$this->storage->deleteFile($path);
325+
}
326+
327+
/**
328+
* Provide sizes for resizeFile test
329+
*/
330+
public function getThumbnailsSizes(): array
331+
{
332+
return [
333+
[
334+
[
335+
'width' => 1024,
336+
'height' => 768,
337+
],
338+
true
339+
],
340+
[
341+
[
342+
'width' => 20,
343+
'height' => 20,
344+
],
345+
false
346+
]
347+
];
348+
}
349+
298350
/**
299351
* Provide scenarios for testing getThumbnailUrl()
300352
*

0 commit comments

Comments
 (0)