12 class CssTest extends \PHPUnit\Framework\TestCase
36 $this->_objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
37 $this->urlBuilder = $this->createMock(\
Magento\Backend\Model\Url::class);
38 $this->urlCoder = $this->createMock(\
Magento\Framework\Encryption\UrlCoder::class);
40 $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
41 $constructArguments = $objectManagerHelper->getConstructArguments(
42 \
Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css::class,
44 'formFactory' => $this->createMock(\
Magento\Framework\Data\FormFactory::class),
45 'objectManager' => $this->_objectManager,
46 'uploaderService' => $this->createMock(\
Magento\Theme\Model\Uploader\Service::class),
47 'urlBuilder' => $this->urlBuilder,
48 'urlCoder' => $this->urlCoder
52 $this->_model = $this->getMockBuilder(\
Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css::class)
53 ->setMethods([
'_getCurrentTheme'])
54 ->setConstructorArgs($constructArguments)
58 public function testGetUploadCssFileNote()
62 $sizeModel = $this->createMock(\
Magento\Framework\File\Size::class);
63 $sizeModel->expects($this->any())->method(
'getMaxFileSizeInMb')->willReturn(
'2M');
65 $this->_objectManager->expects(
70 \
Magento\Framework\File\Size::class
72 $this->returnValue($sizeModel)
76 $expectedResult =
'Allowed file types *.css.<br />';
77 $expectedResult .=
'This file will replace the current custom.css file and can\'t be more than 2 MB.<br />';
78 $expectedResult .= sprintf(
'Max file size to upload %sM', $sizeModel->getMaxFileSizeInMb());
79 $this->assertEquals($expectedResult,
$result);
82 public function testGetAdditionalElementTypes()
87 $configModel = $this->createMock(\
Magento\Framework\
App\Config\ScopeConfigInterface::class);
89 $this->_objectManager->expects(
94 \
Magento\Framework\
App\Config\ScopeConfigInterface::class
96 $this->returnValue($configModel)
101 'links' => \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Form\Element\Links::class,
102 'css_file' => \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Form\Element\File::class,
104 $this->assertEquals($expectedResult,
$result);
109 $this->assertEquals(
'CSS Editor', $this->_model->getTabLabel());
118 $class = new \ReflectionClass(\
Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css::class);
131 $this->urlCoder->expects($this->atLeastOnce())->method(
'encode')->with($fileId)
132 ->will($this->returnValue(
'encoded'));
133 $this->urlBuilder->expects($this->atLeastOnce())->method(
'getUrl')
134 ->with($this->anything(), [
'theme_id' => $themeId,
'file' =>
'encoded']);
135 $this->_model->getDownloadUrl($fileId, $themeId);
$_option $_optionId $class
if(!isset($_GET['name'])) $name