@@ -27,6 +27,11 @@ class LayoutPluginTest extends \PHPUnit\Framework\TestCase
2727 */
2828 protected $ configMock ;
2929
30+ /**
31+ * @var \Magento\Framework\App\MaintenanceMode|\PHPUnit\Framework\MockObject\MockObject
32+ */
33+ private $ maintenanceModeMock ;
34+
3035 protected function setUp ()
3136 {
3237 $ this ->layoutMock = $ this ->getMockForAbstractClass (
@@ -40,27 +45,33 @@ protected function setUp()
4045 );
4146 $ this ->responseMock = $ this ->createMock (\Magento \Framework \App \Response \Http::class);
4247 $ this ->configMock = $ this ->createMock (\Magento \PageCache \Model \Config::class);
48+ $ this ->maintenanceModeMock = $ this ->createMock (\Magento \Framework \App \MaintenanceMode::class);
4349
4450 $ this ->model = new \Magento \PageCache \Model \Layout \LayoutPlugin (
4551 $ this ->responseMock ,
46- $ this ->configMock
52+ $ this ->configMock ,
53+ $ this ->maintenanceModeMock
4754 );
4855 }
4956
5057 /**
5158 * @param $cacheState
5259 * @param $layoutIsCacheable
60+ * @param $maintenanceModeIsEnabled
61+ *
5362 * @dataProvider afterGenerateXmlDataProvider
5463 */
55- public function testAfterGenerateXml ($ cacheState , $ layoutIsCacheable )
64+ public function testAfterGenerateXml ($ cacheState , $ layoutIsCacheable, $ maintenanceModeIsEnabled )
5665 {
5766 $ maxAge = 180 ;
5867 $ result = 'test ' ;
5968
6069 $ this ->layoutMock ->expects ($ this ->once ())->method ('isCacheable ' )->will ($ this ->returnValue ($ layoutIsCacheable ));
6170 $ this ->configMock ->expects ($ this ->any ())->method ('isEnabled ' )->will ($ this ->returnValue ($ cacheState ));
71+ $ this ->maintenanceModeMock ->expects ($ this ->any ())->method ('isOn ' )
72+ ->will ($ this ->returnValue ($ maintenanceModeIsEnabled ));
6273
63- if ($ layoutIsCacheable && $ cacheState ) {
74+ if ($ layoutIsCacheable && $ cacheState && ! $ maintenanceModeIsEnabled ) {
6475 $ this ->configMock ->expects ($ this ->once ())->method ('getTtl ' )->will ($ this ->returnValue ($ maxAge ));
6576 $ this ->responseMock ->expects ($ this ->once ())->method ('setPublicHeaders ' )->with ($ maxAge );
6677 } else {
@@ -76,10 +87,11 @@ public function testAfterGenerateXml($cacheState, $layoutIsCacheable)
7687 public function afterGenerateXmlDataProvider ()
7788 {
7889 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 ],
8395 ];
8496 }
8597
0 commit comments