Skip to content

Commit 7feedea

Browse files
author
Bohdan Korablov
committed
MAGETWO-34559: Impossible to insert a widget as a content for a banner
1 parent bd64b5c commit 7feedea

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public function __construct(
4343
/**
4444
* @return array
4545
*/
46-
protected function getTranslatedString()
46+
protected function getButtonTranslations()
4747
{
48-
$translatedString = [
48+
$buttonTranslations = [
4949
'Insert Image...' => $this->translate('Insert Image...'),
5050
'Insert Media...' => $this->translate('Insert Media...'),
5151
'Insert File...' => $this->translate('Insert File...'),
5252
];
5353

54-
return $translatedString;
54+
return $buttonTranslations;
5555
}
5656

5757
/**
@@ -127,7 +127,7 @@ public function getElementHtml()
127127
"\n" .
128128
'(function($) {$.mage.translate.add(' .
129129
\Zend_Json::encode(
130-
$this->getTranslatedString()
130+
$this->getButtonTranslations()
131131
) .
132132
')})(jQuery);' .
133133
"\n" .
@@ -174,7 +174,7 @@ public function getElementHtml()
174174
//<![CDATA[
175175
require(["jquery", "mage/translate", "mage/adminhtml/wysiwyg/widget"], function(jQuery){
176176
(function($) {
177-
$.mage.translate.add(' . \Zend_Json::encode($this->getTranslatedString()) . ')
177+
$.mage.translate.add(' . \Zend_Json::encode($this->getButtonTranslations()) . ')
178178
})(jQuery);
179179
});
180180
//]]>

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
/**
8-
* Tests for \Magento\Framework\Data\Form\Element\Textarea
8+
* Tests for \Magento\Framework\Data\Form\Element\Editor
99
*/
1010
namespace Magento\Framework\Data\Test\Unit\Form\Element;
1111

@@ -34,7 +34,7 @@ class EditorTest extends \PHPUnit_Framework_TestCase
3434
protected $escaperMock;
3535

3636
/**
37-
* @var \Magento\Framework\Object
37+
* @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject
3838
*/
3939
protected $formMock;
4040

@@ -43,8 +43,14 @@ class EditorTest extends \PHPUnit_Framework_TestCase
4343
*/
4444
protected $configMock;
4545

46+
/**
47+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
48+
*/
49+
protected $objectManager;
50+
4651
protected function setUp()
4752
{
53+
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
4854
$this->factoryMock = $this->getMock('\Magento\Framework\Data\Form\Element\Factory', [], [], '', false);
4955
$this->collectionFactoryMock = $this->getMock(
5056
'\Magento\Framework\Data\Form\Element\CollectionFactory',
@@ -56,11 +62,14 @@ protected function setUp()
5662
$this->escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false);
5763
$this->configMock = $this->getMock('\Magento\Framework\Object', ['getData'], [], '', false);
5864

59-
$this->model = new Editor(
60-
$this->factoryMock,
61-
$this->collectionFactoryMock,
62-
$this->escaperMock,
63-
['config' => $this->configMock]
65+
$this->model = $this->objectManager->getObject(
66+
'Magento\Framework\Data\Form\Element\Editor',
67+
[
68+
'factoryElement' => $this->factoryMock,
69+
'factoryCollection' => $this->collectionFactoryMock,
70+
'escaper' => $this->escaperMock,
71+
'data' => ['config' => $this->configMock]
72+
]
6473
);
6574

6675
$this->formMock = $this->getMock(
@@ -83,11 +92,14 @@ public function testConstruct()
8392

8493
$this->configMock->expects($this->once())->method('getData')->with('enabled')->willReturn(true);
8594

86-
$model = new Editor(
87-
$this->factoryMock,
88-
$this->collectionFactoryMock,
89-
$this->escaperMock,
90-
['config' => $this->configMock]
95+
$model = $this->objectManager->getObject(
96+
'Magento\Framework\Data\Form\Element\Editor',
97+
[
98+
'factoryElement' => $this->factoryMock,
99+
'factoryCollection' => $this->collectionFactoryMock,
100+
'escaper' => $this->escaperMock,
101+
'data' => ['config' => $this->configMock]
102+
]
91103
);
92104

93105
$this->assertEquals('wysiwyg', $model->getType());

0 commit comments

Comments
 (0)