Skip to content

Commit 4d37719

Browse files
committed
#21756: Static test fix.
1 parent c6affac commit 4d37719

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

lib/internal/Magento/Framework/View/Asset/MergeStrategy/Direct.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Framework\View\Asset\MergeStrategy;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Math\Random;
911
use Magento\Framework\View\Asset;
1012

1113
/**
@@ -31,27 +33,27 @@ class Direct implements \Magento\Framework\View\Asset\MergeStrategyInterface
3133
private $cssUrlResolver;
3234

3335
/**
34-
* @var \Magento\Framework\Math\Random
36+
* @var Random
3537
*/
3638
private $mathRandom;
3739

3840
/**
3941
* @param \Magento\Framework\Filesystem $filesystem
4042
* @param \Magento\Framework\View\Url\CssResolver $cssUrlResolver
41-
* @param \Magento\Framework\Math\Random|null $mathRandom
43+
* @param Random|null $mathRandom
4244
*/
4345
public function __construct(
4446
\Magento\Framework\Filesystem $filesystem,
4547
\Magento\Framework\View\Url\CssResolver $cssUrlResolver,
46-
\Magento\Framework\Math\Random $mathRandom = null
48+
Random $mathRandom = null
4749
) {
4850
$this->filesystem = $filesystem;
4951
$this->cssUrlResolver = $cssUrlResolver;
50-
$this->mathRandom = $mathRandom ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Math\Random::class);;
52+
$this->mathRandom = $mathRandom ?: ObjectManager::getInstance()->get(Random::class);
5153
}
5254

5355
/**
54-
* {@inheritdoc}
56+
* @inheritdoc
5557
*/
5658
public function merge(array $assetsToMerge, Asset\LocalInterface $resultAsset)
5759
{
@@ -67,10 +69,9 @@ public function merge(array $assetsToMerge, Asset\LocalInterface $resultAsset)
6769
/**
6870
* Merge files together and modify content if needed
6971
*
70-
* @param \Magento\Framework\View\Asset\MergeableInterface[] $assetsToMerge
71-
* @param \Magento\ Framework\View\Asset\LocalInterface $resultAsset
72-
* @return string
73-
* @throws \Magento\Framework\Exception\LocalizedException
72+
* @param array $assetsToMerge
73+
* @param Asset\LocalInterface $resultAsset
74+
* @return array|string
7475
*/
7576
private function composeMergedContent(array $assetsToMerge, Asset\LocalInterface $resultAsset)
7677
{

lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeStrategy/DirectTest.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
*/
66
namespace Magento\Framework\View\Test\Unit\Asset\MergeStrategy;
77

8-
use Magento\Framework\Filesystem\Directory\WriteInterface;
9-
use \Magento\Framework\View\Asset\MergeStrategy\Direct;
10-
118
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Filesystem\Directory\WriteInterface;
10+
use Magento\Framework\View\Asset\MergeStrategy\Direct;
1211

12+
/**
13+
* Test for Magento\Framework\View\Asset\MergeStrategy\Direct.
14+
*/
1315
class DirectTest extends \PHPUnit\Framework\TestCase
1416
{
1517
/**
@@ -69,7 +71,8 @@ public function testMergeNoAssets()
6971
->method('getUniqueHash')
7072
->willReturn($uniqId);
7173
$this->tmpDir->expects($this->once())->method('writeFile')->with('foo/result' . $uniqId, '');
72-
$this->tmpDir->expects($this->once())->method('renameFile')->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
74+
$this->tmpDir->expects($this->once())->method('renameFile')
75+
->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
7376
$this->object->merge([], $this->resultAsset);
7477
}
7578

@@ -83,7 +86,8 @@ public function testMergeGeneric()
8386
->method('getUniqueHash')
8487
->willReturn($uniqId);
8588
$this->tmpDir->expects($this->once())->method('writeFile')->with('foo/result' . $uniqId, 'onetwo');
86-
$this->tmpDir->expects($this->once())->method('renameFile')->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
89+
$this->tmpDir->expects($this->once())->method('renameFile')
90+
->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
8791
$this->object->merge($assets, $this->resultAsset);
8892
}
8993

@@ -92,7 +96,7 @@ public function testMergeCss()
9296
$uniqId = '_f929c374767e00712449660ea673f2f5';
9397
$this->resultAsset->expects($this->exactly(3))
9498
->method('getPath')
95-
->will($this->returnValue('foo/result'));
99+
->willReturn('foo/result');
96100
$this->resultAsset->expects($this->any())->method('getContentType')->will($this->returnValue('css'));
97101
$assets = $this->prepareAssetsToMerge(['one', 'two']);
98102
$this->cssUrlResolver->expects($this->exactly(2))
@@ -101,13 +105,14 @@ public function testMergeCss()
101105
$this->cssUrlResolver->expects($this->once())
102106
->method('aggregateImportDirectives')
103107
->with('12')
104-
->will($this->returnValue('1020'));
108+
->willReturn('1020');
105109
$this->mathRandomMock->expects($this->once())
106110
->method('getUniqueHash')
107111
->willReturn($uniqId);
108112
$this->staticDir->expects($this->never())->method('writeFile');
109113
$this->tmpDir->expects($this->once())->method('writeFile')->with('foo/result' . $uniqId, '1020');
110-
$this->tmpDir->expects($this->once())->method('renameFile')->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
114+
$this->tmpDir->expects($this->once())->method('renameFile')
115+
->with('foo/result' . $uniqId, 'foo/result', $this->staticDir);
111116
$this->object->merge($assets, $this->resultAsset);
112117
}
113118

0 commit comments

Comments
 (0)