6
6
namespace Magento \Framework ;
7
7
8
8
use Magento \TestFramework \Helper \Bootstrap ;
9
+ use Magento \Framework \Phrase ;
9
10
10
11
class TranslateCachingTest extends \PHPUnit_Framework_TestCase
11
12
{
12
- public static function tearDownAfterClass ()
13
+ /**
14
+ * @var \Magento\Framework\Phrase\RendererInterface
15
+ */
16
+ protected $ renderer ;
17
+
18
+ /**
19
+ * @var \Magento\Framework\ObjectManagerInterface
20
+ */
21
+ protected $ objectManager ;
22
+
23
+ protected function setUp ()
13
24
{
14
- $ objectManager = Bootstrap::getObjectManager ();
25
+ $ this ->objectManager = Bootstrap::getObjectManager ();
26
+ $ this ->renderer = Phrase::getRenderer ();
27
+ Phrase::setRenderer ($ this ->objectManager ->get ('\Magento\Framework\Phrase\RendererInterface ' ));
28
+ }
29
+
30
+ protected function tearDown ()
31
+ {
32
+ Phrase::setRenderer ($ this ->renderer );
33
+
15
34
/** @var \Magento\Framework\App\Cache\Type\Translate $cache */
16
- $ cache = $ objectManager ->get ('Magento\Framework\App\Cache\Type\Translate ' );
35
+ $ cache = $ this -> objectManager ->get ('Magento\Framework\App\Cache\Type\Translate ' );
17
36
$ cache ->clean ();
18
37
}
19
38
@@ -22,27 +41,26 @@ public static function tearDownAfterClass()
22
41
*/
23
42
public function testLoadDataCaching ()
24
43
{
25
- $ objectManager = Bootstrap::getObjectManager ();
26
44
/** @var \Magento\Framework\Translate $model */
27
- $ model = $ objectManager ->get ('Magento\Framework\Translate ' );
45
+ $ model = $ this -> objectManager ->get ('Magento\Framework\Translate ' );
28
46
29
47
$ model ->loadData (\Magento \Framework \App \Area::AREA_FRONTEND ); // this is supposed to cache the fixture
30
- $ this ->assertEquals ('Fixture Db Translation ' , new \ Magento \ Framework \ Phrase ('Fixture String ' ));
48
+ $ this ->assertEquals ('Fixture Db Translation ' , new Phrase ('Fixture String ' ));
31
49
32
50
/** @var \Magento\Translation\Model\Resource\String $translateString */
33
- $ translateString = $ objectManager ->create ('Magento\Translation\Model\Resource\String ' );
51
+ $ translateString = $ this -> objectManager ->create ('Magento\Translation\Model\Resource\String ' );
34
52
$ translateString ->saveTranslate ('Fixture String ' , 'New Db Translation ' );
35
53
36
54
$ this ->assertEquals (
37
55
'Fixture Db Translation ' ,
38
- new \ Magento \ Framework \ Phrase ('Fixture String ' ),
56
+ new Phrase ('Fixture String ' ),
39
57
'Translation is expected to be cached '
40
58
);
41
59
42
60
$ model ->loadData (\Magento \Framework \App \Area::AREA_FRONTEND , true );
43
61
$ this ->assertEquals (
44
62
'New Db Translation ' ,
45
- new \ Magento \ Framework \ Phrase ('Fixture String ' ),
63
+ new Phrase ('Fixture String ' ),
46
64
'Forced load should not use cache '
47
65
);
48
66
}
0 commit comments