@@ -27,6 +27,11 @@ class LayoutPluginTest extends \PHPUnit\Framework\TestCase
27
27
*/
28
28
protected $ configMock ;
29
29
30
+ /**
31
+ * @var \Magento\Framework\App\MaintenanceMode|\PHPUnit\Framework\MockObject\MockObject
32
+ */
33
+ private $ maintenanceModeMock ;
34
+
30
35
protected function setUp ()
31
36
{
32
37
$ this ->layoutMock = $ this ->getMockForAbstractClass (
@@ -40,27 +45,33 @@ protected function setUp()
40
45
);
41
46
$ this ->responseMock = $ this ->createMock (\Magento \Framework \App \Response \Http::class);
42
47
$ this ->configMock = $ this ->createMock (\Magento \PageCache \Model \Config::class);
48
+ $ this ->maintenanceModeMock = $ this ->createMock (\Magento \Framework \App \MaintenanceMode::class);
43
49
44
50
$ this ->model = new \Magento \PageCache \Model \Layout \LayoutPlugin (
45
51
$ this ->responseMock ,
46
- $ this ->configMock
52
+ $ this ->configMock ,
53
+ $ this ->maintenanceModeMock
47
54
);
48
55
}
49
56
50
57
/**
51
58
* @param $cacheState
52
59
* @param $layoutIsCacheable
60
+ * @param $maintenanceModeIsEnabled
61
+ *
53
62
* @dataProvider afterGenerateXmlDataProvider
54
63
*/
55
- public function testAfterGenerateXml ($ cacheState , $ layoutIsCacheable )
64
+ public function testAfterGenerateXml ($ cacheState , $ layoutIsCacheable, $ maintenanceModeIsEnabled )
56
65
{
57
66
$ maxAge = 180 ;
58
67
$ result = 'test ' ;
59
68
60
69
$ this ->layoutMock ->expects ($ this ->once ())->method ('isCacheable ' )->will ($ this ->returnValue ($ layoutIsCacheable ));
61
70
$ this ->configMock ->expects ($ this ->any ())->method ('isEnabled ' )->will ($ this ->returnValue ($ cacheState ));
71
+ $ this ->maintenanceModeMock ->expects ($ this ->any ())->method ('isOn ' )
72
+ ->will ($ this ->returnValue ($ maintenanceModeIsEnabled ));
62
73
63
- if ($ layoutIsCacheable && $ cacheState ) {
74
+ if ($ layoutIsCacheable && $ cacheState && ! $ maintenanceModeIsEnabled ) {
64
75
$ this ->configMock ->expects ($ this ->once ())->method ('getTtl ' )->will ($ this ->returnValue ($ maxAge ));
65
76
$ this ->responseMock ->expects ($ this ->once ())->method ('setPublicHeaders ' )->with ($ maxAge );
66
77
} else {
@@ -76,10 +87,11 @@ public function testAfterGenerateXml($cacheState, $layoutIsCacheable)
76
87
public function afterGenerateXmlDataProvider ()
77
88
{
78
89
return [
79
- 'Full_cache state is true, Layout is cache-able ' => [true , true ],
80
- 'Full_cache state is true, Layout is not cache-able ' => [true , false ],
81
- 'Full_cache state is false, Layout is not cache-able ' => [false , false ],
82
- 'Full_cache state is false, Layout is cache-able ' => [false , true ]
90
+ 'Full_cache state is true, Layout is cache-able ' => [true , true , false ],
91
+ 'Full_cache state is true, Layout is not cache-able ' => [true , false , false ],
92
+ 'Full_cache state is false, Layout is not cache-able ' => [false , false , false ],
93
+ 'Full_cache state is false, Layout is cache-able ' => [false , true , false ],
94
+ 'Full_cache state is true, Layout is cache-able, Maintenance mode is enabled ' => [true , true , true ],
83
95
];
84
96
}
85
97
0 commit comments