8
8
use \Magento \Framework \View \Asset \MergeStrategy \Checksum ;
9
9
10
10
use Magento \Framework \App \Filesystem \DirectoryList ;
11
+ use Magento \Framework \View \Asset \Source ;
11
12
12
13
class ChecksumTest extends \PHPUnit_Framework_TestCase
13
14
{
@@ -31,6 +32,11 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase
31
32
*/
32
33
private $ resultAsset ;
33
34
35
+ /**
36
+ * @var Source|\PHPUnit_Framework_MockObject_MockObject
37
+ */
38
+ private $ assetSource ;
39
+
34
40
/**
35
41
* @var \Magento\Framework\View\Asset\MergeStrategy\Checksum
36
42
*/
@@ -53,6 +59,15 @@ protected function setUp()
53
59
->with (DirectoryList::STATIC_VIEW )
54
60
->will ($ this ->returnValue ($ this ->targetDir ));
55
61
$ this ->checksum = new Checksum ($ this ->mergerMock , $ filesystem );
62
+ $ this ->assetSource = $ this ->getMockBuilder (Source::class)
63
+ ->disableOriginalConstructor ()
64
+ ->getMock ();
65
+
66
+ $ reflection = new \ReflectionClass (Checksum::class);
67
+ $ reflectionProperty = $ reflection ->getProperty ('assetSource ' );
68
+ $ reflectionProperty ->setAccessible (true );
69
+ $ reflectionProperty ->setValue ($ this ->checksum , $ this ->assetSource );
70
+
56
71
$ this ->resultAsset = $ this ->getMock (\Magento \Framework \View \Asset \File::class, [], [], '' , false );
57
72
}
58
73
@@ -114,9 +129,17 @@ public function testMergeMtimeUnchanged()
114
129
private function getAssetsToMerge ()
115
130
{
116
131
$ one = $ this ->getMock (\Magento \Framework \View \Asset \File::class, [], [], '' , false );
117
- $ one ->expects ($ this ->once ())->method ('getSourceFile ' )->will ($ this ->returnValue ('/dir/file/one.txt ' ));
118
132
$ two = $ this ->getMock (\Magento \Framework \View \Asset \File::class, [], [], '' , false );
119
- $ two ->expects ($ this ->once ())->method ('getSourceFile ' )->will ($ this ->returnValue ('/dir/file/two.txt ' ));
133
+ $ one ->expects ($ this ->never ())
134
+ ->method ('getSourceFile ' );
135
+ $ two ->expects ($ this ->never ())
136
+ ->method ('getSourceFile ' );
137
+
138
+ $ this ->assetSource ->expects ($ this ->exactly (2 ))
139
+ ->method ('findSource ' )
140
+ ->withConsecutive ([$ one ], [$ two ])
141
+ ->willReturnOnConsecutiveCalls ('/dir/file/one.txt ' , '/dir/file/two.txt ' );
142
+
120
143
$ this ->sourceDir ->expects ($ this ->exactly (2 ))
121
144
->method ('getRelativePath ' )
122
145
->will ($ this ->onConsecutiveCalls ('file/one.txt ' , 'file/two.txt ' ));
0 commit comments