public function AssetImageHelperTest::testGetThumbnailUrlBySize in Media: Acquia DAM 8
Validate we fetch the correct thumbnail size when given varying sizes.
File
- tests/
src/ Unit/ AssetImageHelperTest.php, line 41
Class
- AssetImageHelperTest
- Tests integration of the AssetImageHelper service.
Namespace
Drupal\Tests\media_acquiadam\UnitCode
public function testGetThumbnailUrlBySize() {
$asset = $this
->getAssetData();
// Ensure that we get the smallest size when given something smaller than
// set.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset, 50);
$this
->assertEquals('http://subdomain.webdamdb.com/s/100th_sm_0UerYozlI3.jpg', $tn_url);
// Ensure we can get an exact size.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset, 100);
$this
->assertEquals('http://subdomain.webdamdb.com/s/100th_sm_0UerYozlI3.jpg', $tn_url);
// Ensure we get the closest smallest if available.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset, 120);
$this
->assertEquals('http://subdomain.webdamdb.com/s/100th_sm_0UerYozlI3.jpg', $tn_url);
// Ensure we get the closest smallest for larger sizes.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset, 350);
$this
->assertEquals('http://subdomain.webdamdb.com/s/310th_sm_0UerYozlI3.jpg', $tn_url);
// Ensure we get the biggest if nothing was available.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset, 12000);
$this
->assertEquals('http://subdomain.webdamdb.com/s/md_0UerYozlI3.jpg', $tn_url);
// Ensure we get the biggest when nothing is specified.
$tn_url = $this->assetImageHelper
->getThumbnailUrlBySize($asset);
$this
->assertEquals('http://subdomain.webdamdb.com/s/md_0UerYozlI3.jpg', $tn_url);
}