Set the image size items collection
public setImageSizeItems ( |
||
$imageSizeItems | The image size items collection |
/** * Tests the getTemplateData() method with sources. */ public function testGetTemplateDataWithSources() { $picture = new Picture(new \File('dummy.jpg')); $picture->setImageSize((object) ['width' => 100, 'height' => 100, 'resizeMode' => 'crop', 'zoom' => 0]); $picture->setImageSizeItems([(object) ['width' => 50, 'height' => 50, 'resizeMode' => 'crop', 'zoom' => 0, 'media' => '(max-width: 900px)'], (object) ['width' => 25, 'height' => 25, 'resizeMode' => 'crop', 'zoom' => 0, 'media' => '(max-width: 600px)']]); $pictureData = $picture->getTemplateData(); $this->assertEquals(100, $pictureData['img']['width']); $this->assertEquals(100, $pictureData['img']['height']); $this->assertEquals($pictureData['img']['src'], $pictureData['img']['srcset'], 'Attributes src and srcset should be equal'); $this->assertEquals(50, $pictureData['sources'][0]['width']); $this->assertEquals(50, $pictureData['sources'][0]['height']); $this->assertEquals('(max-width: 900px)', $pictureData['sources'][0]['media']); $this->assertEquals($pictureData['sources'][0]['src'], $pictureData['sources'][0]['srcset'], 'Attributes src and srcset should be equal'); $this->assertEquals(25, $pictureData['sources'][1]['width']); $this->assertEquals(25, $pictureData['sources'][1]['height']); $this->assertEquals('(max-width: 600px)', $pictureData['sources'][1]['media']); $this->assertEquals($pictureData['sources'][1]['src'], $pictureData['sources'][1]['srcset'], 'Attributes src and srcset should be equal'); }