33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+
67namespace Magento \Framework ;
78
89use Magento \TestFramework \Helper \Bootstrap ;
910use Magento \TestFramework \Helper \CacheCleaner ;
11+ use PHPUnit \Framework \TestCase ;
12+ use PHPUnit_Framework_MockObject_MockObject ;
1013
1114/**
1215 * @magentoAppIsolation enabled
1316 * @magentoCache all disabled
1417 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1518 */
16- class TranslateTest extends \ PHPUnit \ Framework \ TestCase
19+ class TranslateTest extends TestCase
1720{
1821 /** @var \Magento\Framework\Translate */
1922 private $ translate ;
2023
2124 protected function setUp ()
2225 {
23- /** @var \Magento\Framework\View\FileSystem $viewFileSystem */
26+ /** @var \Magento\Framework\View\FileSystem | PHPUnit_Framework_MockObject_MockObject $viewFileSystem */
2427 $ viewFileSystem = $ this ->createPartialMock (
2528 \Magento \Framework \View \FileSystem::class,
26- ['getLocaleFileName ' , ' getDesignTheme ' ]
29+ ['getLocaleFileName ' ]
2730 );
2831
2932 $ viewFileSystem ->expects ($ this ->any ())
3033 ->method ('getLocaleFileName ' )
3134 ->will (
32- $ this ->returnValue (dirname (__DIR__ ) . '/Theme/Model/_files/design/frontend/Test/default/i18n/en_US.csv ' )
35+ $ this ->returnValue (
36+ dirname (__DIR__ ) . '/Translation/Model/_files/Magento/design/Magento/theme/i18n/en_US.csv '
37+ )
3338 );
3439
35- /** @var \Magento\Framework\View\Design\ThemeInterface $theme */
40+ /** @var \Magento\Framework\View\Design\ThemeInterface | PHPUnit_Framework_MockObject_MockObject $theme */
3641 $ theme = $ this ->createMock (\Magento \Framework \View \Design \ThemeInterface::class);
37- $ theme ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue (10 ));
38-
39- $ viewFileSystem ->expects ($ this ->any ())->method ('getDesignTheme ' )->will ($ this ->returnValue ($ theme ));
42+ $ theme ->expects ($ this ->any ())->method ('getThemePath ' )->will ($ this ->returnValue ('Magento/luma ' ));
4043
4144 /** @var \Magento\TestFramework\ObjectManager $objectManager */
4245 $ objectManager = Bootstrap::getObjectManager ();
@@ -55,7 +58,7 @@ protected function setUp()
5558 dirname (__DIR__ ) . '/Translation/Model/_files/Magento/Catalog/i18n '
5659 );
5760
58- /** @var \Magento\Theme\Model\View\Design $designModel */
61+ /** @var \Magento\Theme\Model\View\Design | \PHPUnit_Framework_MockObject_MockObject $designModel */
5962 $ designModel = $ this ->getMockBuilder (\Magento \Theme \Model \View \Design::class)
6063 ->setMethods (['getDesignTheme ' ])
6164 ->setConstructorArgs (
@@ -96,6 +99,9 @@ public function testLoadData()
9699 /**
97100 * @magentoCache all disabled
98101 * @dataProvider translateDataProvider
102+ * @param string $inputText
103+ * @param string $expectedTranslation
104+ * @throws Exception\LocalizedException
99105 */
100106 public function testTranslate ($ inputText , $ expectedTranslation )
101107 {
@@ -111,9 +117,26 @@ public function translateDataProvider()
111117 {
112118 return [
113119 ['' , '' ],
114- ['Text with different translation on different modules ' , 'Text translation that was last loaded ' ],
115- ['text_with_no_translation ' , 'text_with_no_translation ' ],
116- ['Design value to translate ' , 'Design translated value ' ]
120+ [
121+ 'Theme phrase will be translated ' ,
122+ 'Theme phrase is translated ' ,
123+ ],
124+ [
125+ 'Phrase in Magento_Store module that doesn \'t need translation ' ,
126+ 'Phrase in Magento_Store module that doesn \'t need translation ' ,
127+ ],
128+ [
129+ 'Phrase in Magento_Catalog module that doesn \'t need translation ' ,
130+ 'Phrase in Magento_Catalog module that doesn \'t need translation ' ,
131+ ],
132+ [
133+ 'Magento_Store module phrase will be override by theme translation ' ,
134+ 'Magento_Store module phrase is override by theme translation ' ,
135+ ],
136+ [
137+ 'Magento_Catalog module phrase will be override by theme translation ' ,
138+ 'Magento_Catalog module phrase is override by theme translation ' ,
139+ ],
117140 ];
118141 }
119142}
0 commit comments