3
3
* Copyright © 2015 Magento. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
-
7
6
namespace Magento \Developer \Test \Unit \Model \Css \PreProcessor \FileGenerator ;
8
7
9
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
8
+ use Magento \Framework \Filesystem ;
9
+ use Magento \Framework \Css \PreProcessor \File \Temporary ;
10
+ use Magento \Developer \Model \Css \PreProcessor \FileGenerator \PublicationDecorator ;
10
11
12
+ /**
13
+ * Class PublicationDecoratorTest
14
+ */
11
15
class PublicationDecoratorTest extends \PHPUnit_Framework_TestCase
12
16
{
13
17
/**
14
18
* Calls generate method to access protected method generateRelatedFile
15
19
*/
16
20
public function testGenerateRelatedFile ()
17
21
{
22
+ $ filesystemMock = $ this ->getMockBuilder (Filesystem::class)
23
+ ->disableOriginalConstructor ()
24
+ ->getMock ();
25
+ $ fileTemporaryMock = $ this ->getMockBuilder (Temporary::class)
26
+ ->disableOriginalConstructor ()
27
+ ->getMock ();
28
+
18
29
$ publisherMock = $ this ->getMockBuilder ('Magento\Framework\App\View\Asset\Publisher ' )
19
30
->disableOriginalConstructor ()
20
31
->getMock ();
@@ -33,24 +44,24 @@ public function testGenerateRelatedFile()
33
44
$ relatedFileId = 'file_id ' ;
34
45
35
46
$ relatedFiles = [[$ relatedFileId , $ localAssetMock ]];
36
- $ importGeneratorMock ->expects ($ this ->any ())
47
+
48
+ $ importGeneratorMock ->expects (self ::any ())
37
49
->method ('getRelatedFiles ' )
38
- ->will ($ this ->onConsecutiveCalls ($ relatedFiles , []));
39
- $ assetRepoMock ->expects ($ this ->any ())
50
+ ->will (self ::onConsecutiveCalls ($ relatedFiles , []));
51
+
52
+ $ assetRepoMock ->expects (self ::any ())
40
53
->method ('createRelated ' )
41
54
->willReturn ($ relatedAssetMock );
42
- $ publisherMock ->expects ($ this ->once ())
55
+
56
+ $ publisherMock ->expects (self ::once ())
43
57
->method ('publish ' )
44
58
->with ($ relatedAssetMock );
45
59
46
- $ args = [
47
- 'assetRepo ' => $ assetRepoMock ,
48
- 'publisher ' => $ publisherMock
49
- ];
50
-
51
- $ model = (new ObjectManager ($ this ))->getObject (
52
- 'Magento\Developer\Model\Css\PreProcessor\FileGenerator\PublicationDecorator ' ,
53
- $ args
60
+ $ model = new PublicationDecorator (
61
+ $ filesystemMock ,
62
+ $ assetRepoMock ,
63
+ $ fileTemporaryMock ,
64
+ $ publisherMock
54
65
);
55
66
56
67
$ model ->generate ($ importGeneratorMock );
0 commit comments