/** * Tests the getTemplateData() method with encoded file names. */ public function testGetTemplateDataUrlEncoded() { copy(__DIR__ . '/../Fixtures/images/dummy.jpg', self::$rootDir . '/dummy with spaces.jpg'); $picture = new Picture(new \File('dummy with spaces.jpg')); $picture->setImageSize((object) ['width' => 0, 'height' => 0, 'resizeMode' => '', 'zoom' => 0]); $pictureData = $picture->getTemplateData(); $this->assertEquals(200, $pictureData['img']['width']); $this->assertEquals(200, $pictureData['img']['height']); $this->assertEquals('dummy%20with%20spaces.jpg', $pictureData['img']['src']); $this->assertEquals('dummy%20with%20spaces.jpg', $pictureData['img']['srcset']); $this->assertEquals([], $pictureData['sources']); }
/** * Tests the getTemplateData() method with an old resize mode. */ public function testGetTemplateDataOldResizeMode() { $picture = new Picture(new \File('dummy.jpg')); $picture->setImageSize((object) ['width' => 100, 'height' => 100, 'resizeMode' => 'center_center', 'zoom' => 0]); $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([], $pictureData['sources']); }