@@ -20,6 +20,9 @@ class MediaTest extends \PHPUnit\Framework\TestCase
20
20
/** @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */
21
21
private $ productModelFactoryMock ;
22
22
23
+ /** @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
24
+ private $ config ;
25
+
23
26
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
24
27
private $ productMock ;
25
28
@@ -29,6 +32,9 @@ class MediaTest extends \PHPUnit\Framework\TestCase
29
32
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
30
33
private $ requestMock ;
31
34
35
+ /** @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
36
+ private $ responseMock ;
37
+
32
38
/** @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */
33
39
private $ resultFactory ;
34
40
@@ -57,11 +63,20 @@ protected function setUp()
57
63
\Magento \Catalog \Model \ProductFactory::class,
58
64
['create ' ]
59
65
);
66
+ $ this ->config = $ this ->createMock (\Magento \PageCache \Model \Config::class);
67
+ $ this ->config ->method ('getTtl ' )->willReturn (1 );
68
+
60
69
$ this ->productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
61
70
$ this ->contextMock = $ this ->createMock (\Magento \Framework \App \Action \Context::class);
62
71
63
72
$ this ->requestMock = $ this ->createMock (\Magento \Framework \App \RequestInterface::class);
64
73
$ this ->contextMock ->method ('getRequest ' )->willReturn ($ this ->requestMock );
74
+ $ this ->responseMock = $ this ->getMockBuilder (\Magento \Framework \App \ResponseInterface::class)
75
+ ->disableOriginalConstructor ()
76
+ ->setMethods (['setPublicHeaders ' ])
77
+ ->getMockForAbstractClass ();
78
+ $ this ->responseMock ->method ('setPublicHeaders ' )->willReturnSelf ();
79
+ $ this ->contextMock ->method ('getResponse ' )->willReturn ($ this ->responseMock );
65
80
$ this ->resultFactory = $ this ->createPartialMock (\Magento \Framework \Controller \ResultFactory::class, ['create ' ]);
66
81
$ this ->contextMock ->method ('getResultFactory ' )->willReturn ($ this ->resultFactory );
67
82
@@ -73,7 +88,8 @@ protected function setUp()
73
88
[
74
89
'context ' => $ this ->contextMock ,
75
90
'swatchHelper ' => $ this ->swatchHelperMock ,
76
- 'productModelFactory ' => $ this ->productModelFactoryMock
91
+ 'productModelFactory ' => $ this ->productModelFactoryMock ,
92
+ 'config ' => $ this ->config
77
93
]
78
94
);
79
95
}
@@ -86,6 +102,10 @@ public function testExecute()
86
102
->method ('load ' )
87
103
->with (59 )
88
104
->willReturn ($ this ->productMock );
105
+ $ this ->productMock
106
+ ->expects ($ this ->once ())
107
+ ->method ('getIdentities ' )
108
+ ->willReturn (['tags ' ]);
89
109
90
110
$ this ->productModelFactoryMock
91
111
->expects ($ this ->once ())
0 commit comments