Skip to content

Commit fe73cf0

Browse files
committed
#17833:  Child theme does not inherit translations from parent theme
- forward port unit tests from 2.2-develop branch - declare strict types
1 parent 57fcc1b commit fe73cf0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/internal/Magento/Framework/Test/Unit/TranslateTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Framework\Test\Unit;
79

810
use Magento\Framework\Serialize\SerializerInterface;
@@ -61,7 +63,7 @@ class TranslateTest extends \PHPUnit\Framework\TestCase
6163
/** @var \Magento\Framework\Filesystem\DriverInterface|\PHPUnit_Framework_MockObject_MockObject */
6264
protected $fileDriver;
6365

64-
protected function setUp()
66+
protected function setUp(): void
6567
{
6668
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
6769
$this->viewDesign = $this->createMock(\Magento\Framework\View\DesignInterface::class);
@@ -128,7 +130,7 @@ protected function setUp()
128130
* @param array $cachedData
129131
* @dataProvider dataProviderLoadDataCachedTranslation
130132
*/
131-
public function testLoadDataCachedTranslation($area, $forceReload, $cachedData)
133+
public function testLoadDataCachedTranslation($area, $forceReload, $cachedData): void
132134
{
133135
$this->expectsSetConfig('Magento/luma');
134136

@@ -147,7 +149,7 @@ public function testLoadDataCachedTranslation($area, $forceReload, $cachedData)
147149
/**
148150
* @return array
149151
*/
150-
public function dataProviderLoadDataCachedTranslation()
152+
public function dataProviderLoadDataCachedTranslation(): array
151153
{
152154
$cachedData = ['cached 1' => 'translated 1', 'cached 2' => 'translated 2'];
153155
return [
@@ -163,7 +165,7 @@ public function dataProviderLoadDataCachedTranslation()
163165
* @dataProvider dataProviderForTestLoadData
164166
* @SuppressWarnings(PHPMD.NPathComplexity)
165167
*/
166-
public function testLoadData($area, $forceReload)
168+
public function testLoadData($area, $forceReload): void
167169
{
168170
$this->expectsSetConfig('Magento/luma');
169171

@@ -258,7 +260,7 @@ public function testLoadData($area, $forceReload)
258260
/**
259261
* @return array
260262
*/
261-
public function dataProviderForTestLoadData()
263+
public function dataProviderForTestLoadData(): array
262264
{
263265
return [
264266
['adminhtml', true],
@@ -275,7 +277,7 @@ public function dataProviderForTestLoadData()
275277
* @param $result
276278
* @dataProvider dataProviderForTestGetData
277279
*/
278-
public function testGetData($data, $result)
280+
public function testGetData($data, $result): void
279281
{
280282
$this->cache->expects($this->once())
281283
->method('load')
@@ -288,7 +290,7 @@ public function testGetData($data, $result)
288290
/**
289291
* @return array
290292
*/
291-
public function dataProviderForTestGetData()
293+
public function dataProviderForTestGetData(): array
292294
{
293295
$data = ['original 1' => 'translated 1', 'original 2' => 'translated 2'];
294296
return [
@@ -297,7 +299,7 @@ public function dataProviderForTestGetData()
297299
];
298300
}
299301

300-
public function testGetLocale()
302+
public function testGetLocale(): void
301303
{
302304
$this->locale->expects($this->once())->method('getLocale')->will($this->returnValue('en_US'));
303305
$this->assertEquals('en_US', $this->translate->getLocale());
@@ -310,14 +312,14 @@ public function testGetLocale()
310312
$this->assertEquals('en_GB', $this->translate->getLocale());
311313
}
312314

313-
public function testSetLocale()
315+
public function testSetLocale(): void
314316
{
315317
$this->translate->setLocale('en_GB');
316318
$this->locale->expects($this->never())->method('getLocale');
317319
$this->assertEquals('en_GB', $this->translate->getLocale());
318320
}
319321

320-
public function testGetTheme()
322+
public function testGetTheme(): void
321323
{
322324
$this->request->expects($this->at(0))->method('getParam')->with('theme')->will($this->returnValue(''));
323325

@@ -329,7 +331,7 @@ public function testGetTheme()
329331
$this->assertEquals('themeTheme Title', $this->translate->getTheme());
330332
}
331333

332-
public function testLoadDataNoTheme()
334+
public function testLoadDataNoTheme(): void
333335
{
334336
$forceReload = true;
335337
$this->expectsSetConfig(null, null);
@@ -343,7 +345,7 @@ public function testLoadDataNoTheme()
343345
/**
344346
* Declare calls expectation for setConfig() method
345347
*/
346-
protected function expectsSetConfig($themeId, $localeCode = 'en_US')
348+
protected function expectsSetConfig($themeId, $localeCode = 'en_US'): void
347349
{
348350
$this->locale->expects($this->any())->method('getLocale')->will($this->returnValue($localeCode));
349351
$scope = new \Magento\Framework\DataObject(['code' => 'frontendCode', 'id' => 1]);

0 commit comments

Comments
 (0)