public function testGetElementHtml() { $filePath = 'some/path/to/file.jpg'; $this->imageElement->setValue($filePath); $html = $this->imageElement->getElementHtml(); $this->assertContains('media/' . $filePath, $html); }
/** * @covers \Magento\Framework\Data\Form\Element\Image::getElementHtml */ public function testGetElementHtmlWithValue() { $this->_image->setValue('test_value'); $html = $this->_image->getElementHtml(); $this->assertContains('class="input-file"', $html); $this->assertContains('<input', $html); $this->assertContains('type="file"', $html); $this->assertContains('value="test_value"', $html); $this->assertContains('<a href="test_value" onclick="imagePreview(\'_image\'); return false;"', $html); $this->assertContains('<input type="checkbox"', $html); }
/** * @covers \Magento\Framework\Data\Form\Element\Image::getElementHtml */ public function testGetElementHtmlWithValue() { $this->_image->setValue('test_value'); $this->urlBuilder->expects($this->once())->method('getBaseUrl')->with(['_type' => UrlInterface::URL_TYPE_MEDIA])->willReturn('http://localhost/media/'); $html = $this->_image->getElementHtml(); $this->assertContains('class="input-file"', $html); $this->assertContains('<input', $html); $this->assertContains('type="file"', $html); $this->assertContains('value="test_value"', $html); $this->assertContains('<a href="http://localhost/media/test_value" onclick="imagePreview(\'_image\'); return false;"', $html); $this->assertContains('<input type="checkbox"', $html); }