コード例 #1
0
 /**
  * @covers \Magento\Config\Block\System\Config\Form\Field\Image::_getUrl
  */
 public function testGetElementHtmlWithValue()
 {
     $type = 'media';
     $url = 'http://test.example.com/media/';
     $this->urlBuilderMock->expects($this->once())->method('getBaseUrl')->with(['_type' => $type])->will($this->returnValue($url));
     $this->_image->setValue('test_value');
     $this->_image->setFieldConfig(['id' => 'placeholder', 'type' => 'image', 'sortOrder' => '1', 'showInDefault' => '1', 'showInWebsite' => '1', 'showInStore' => '1', 'label' => null, 'backend_model' => 'Magento\\Backend\\Model\\Config\\Backend\\Image', 'upload_dir' => ['config' => 'system/filesystem/media', 'scope_info' => '1', 'value' => 'catalog/product/placeholder'], 'base_url' => ['type' => $type, 'scope_info' => '1', 'value' => 'catalog/product/placeholder'], '_elementType' => 'field', 'path' => 'catalog/placeholder']);
     $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="' . $url . 'catalog/product/placeholder/test_value" onclick="imagePreview(\'_image\'); return false;"', $html);
     $this->assertContains('<input type="checkbox"', $html);
 }