@@ -48,6 +48,11 @@ class EditorTest extends \PHPUnit_Framework_TestCase
48
48
*/
49
49
protected $ objectManager ;
50
50
51
+ /**
52
+ * @var \PHPUnit_Framework_MockObject_MockObject
53
+ */
54
+ private $ serializer ;
55
+
51
56
protected function setUp ()
52
57
{
53
58
$ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
@@ -62,13 +67,16 @@ protected function setUp()
62
67
$ this ->escaperMock = $ this ->getMock (\Magento \Framework \Escaper::class, [], [], '' , false );
63
68
$ this ->configMock = $ this ->getMock (\Magento \Framework \DataObject::class, ['getData ' ], [], '' , false );
64
69
70
+ $ this ->serializer = $ this ->getMock (\Magento \Framework \Serialize \Serializer \Json::class, [], [], '' , false );
71
+
65
72
$ this ->model = $ this ->objectManager ->getObject (
66
73
\Magento \Framework \Data \Form \Element \Editor::class,
67
74
[
68
75
'factoryElement ' => $ this ->factoryMock ,
69
76
'factoryCollection ' => $ this ->collectionFactoryMock ,
70
77
'escaper ' => $ this ->escaperMock ,
71
- 'data ' => ['config ' => $ this ->configMock ]
78
+ 'data ' => ['config ' => $ this ->configMock ],
79
+ 'serializer ' => $ this ->serializer
72
80
]
73
81
);
74
82
@@ -203,7 +211,14 @@ public function testGetConfig()
203
211
public function testGetTranslatedString ()
204
212
{
205
213
$ this ->configMock ->expects ($ this ->any ())->method ('getData ' )->withConsecutive (['enabled ' ])->willReturn (true );
214
+ $ this ->serializer ->expects ($ this ->any ())
215
+ ->method ('serialize ' )
216
+ ->willReturnCallback (function ($ params ) {
217
+ return json_encode ($ params );
218
+ }
219
+ );
206
220
$ html = $ this ->model ->getElementHtml ();
221
+
207
222
$ this ->assertRegExp ('/.*"Insert Image...":"Insert Image...".*/i ' , $ html );
208
223
}
209
224
}
0 commit comments