@@ -19,6 +19,11 @@ class PhraseTest extends \PHPUnit_Framework_TestCase
19
19
*/
20
20
protected $ rendererMock ;
21
21
22
+ /**
23
+ * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
24
+ */
25
+ protected $ objectManager ;
26
+
22
27
/**
23
28
* SetUp method
24
29
*
@@ -29,6 +34,7 @@ protected function setUp()
29
34
$ this ->defaultRenderer = Phrase::getRenderer ();
30
35
$ this ->rendererMock = $ this ->getMockBuilder ('Magento\Framework\Phrase\RendererInterface ' )
31
36
->getMock ();
37
+ $ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
32
38
}
33
39
34
40
/**
@@ -51,7 +57,10 @@ public function testRendering()
51
57
$ text = 'some text ' ;
52
58
$ arguments = ['arg1 ' , 'arg2 ' ];
53
59
$ result = 'rendered text ' ;
54
- $ phrase = new Phrase ($ text , $ arguments );
60
+ $ phrase = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
61
+ 'text ' => $ text ,
62
+ 'arguments ' => $ arguments ,
63
+ ]);
55
64
Phrase::setRenderer ($ this ->rendererMock );
56
65
57
66
$ this ->rendererMock ->expects ($ this ->once ())
@@ -72,7 +81,9 @@ public function testDefersRendering()
72
81
$ this ->rendererMock ->expects ($ this ->never ())
73
82
->method ('render ' );
74
83
75
- new Phrase ('some text ' );
84
+ $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
85
+ 'text ' => 'some text ' ,
86
+ ]);
76
87
}
77
88
78
89
/**
@@ -85,7 +96,10 @@ public function testThatToStringIsAliasToRender()
85
96
$ text = 'some text ' ;
86
97
$ arguments = ['arg1 ' , 'arg2 ' ];
87
98
$ result = 'rendered text ' ;
88
- $ phrase = new Phrase ($ text , $ arguments );
99
+ $ phrase = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
100
+ 'text ' => $ text ,
101
+ 'arguments ' => $ arguments ,
102
+ ]);
89
103
Phrase::setRenderer ($ this ->rendererMock );
90
104
91
105
$ this ->rendererMock ->expects ($ this ->once ())
@@ -105,6 +119,9 @@ public function testGetText()
105
119
{
106
120
$ text = 'some text ' ;
107
121
$ phrase = new Phrase ($ text );
122
+ $ phrase = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
123
+ 'text ' => $ text ,
124
+ ]);
108
125
109
126
$ this ->assertEquals ($ text , $ phrase ->getText ());
110
127
}
@@ -118,8 +135,13 @@ public function testGetArguments()
118
135
{
119
136
$ text = 'some text ' ;
120
137
$ arguments = ['arg1 ' , 'arg2 ' ];
121
- $ phrase1 = new Phrase ($ text );
122
- $ phrase2 = new Phrase ($ text , $ arguments );
138
+ $ phrase1 = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
139
+ 'text ' => $ text ,
140
+ ]);
141
+ $ phrase2 = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
142
+ 'text ' => $ text ,
143
+ 'arguments ' => $ arguments ,
144
+ ]);
123
145
124
146
$ this ->assertEquals ([], $ phrase1 ->getArguments ());
125
147
$ this ->assertEquals ($ arguments , $ phrase2 ->getArguments ());
@@ -135,7 +157,10 @@ public function testDefaultRendering()
135
157
$ text = 'parameter1 is replaced by %1 parameter2 is replaced by %2 ' ;
136
158
$ arguments = ['arg1 ' , 'arg2 ' ];
137
159
$ result = 'parameter1 is replaced by arg1 parameter2 is replaced by arg2 ' ;
138
- $ phrase = new Phrase ($ text , $ arguments );
160
+ $ phrase = $ this ->objectManager ->getObject ('Magento\Framework\Phrase ' , [
161
+ 'text ' => $ text ,
162
+ 'arguments ' => $ arguments ,
163
+ ]);
139
164
140
165
$ this ->assertEquals ($ text , $ phrase ->getText ());
141
166
$ this ->assertEquals ($ arguments , $ phrase ->getArguments ());
0 commit comments