63 $this->configMock = $this->createMock(\
Magento\PageCache\Model\Config::class);
64 $this->versionMock = $this->createMock(\
Magento\Framework\
App\PageCache\Version::class);
65 $this->kernelMock = $this->createMock(\
Magento\Framework\
App\PageCache\Kernel::class);
66 $this->stateMock = $this->createMock(\
Magento\Framework\
App\State::class);
67 $this->frontControllerMock = $this->createMock(\
Magento\Framework\
App\FrontControllerInterface::class);
68 $this->requestMock = $this->createMock(\
Magento\Framework\
App\RequestInterface::class);
71 $this->closure =
function () use (
$response) {
74 $this->plugin = new \Magento\PageCache\Model\App\FrontController\BuiltinPlugin(
87 $header = \Zend\Http\Header\GenericHeader::fromString(
'Cache-Control: no-cache');
89 ->expects($this->once())
92 $this->configMock->expects($this->once())
94 ->will($this->returnValue(
true));
96 ->expects($this->once())
99 ->expects($this->once())
101 ->will($this->returnValue(
false));
102 $this->stateMock->expects($this->any())
104 ->will($this->returnValue($state));
105 if ($state == \
Magento\Framework\
App\State::MODE_DEVELOPER) {
106 $this->responseMock->expects($this->at(1))
107 ->method(
'setHeader')
108 ->with(
'X-Magento-Cache-Control');
109 $this->responseMock->expects($this->at(2))
110 ->method(
'setHeader')
111 ->with(
'X-Magento-Cache-Debug',
'MISS',
true);
113 $this->responseMock->expects($this->never())
114 ->method(
'setHeader');
117 ->expects($this->once())
118 ->method(
'getHeader')
119 ->with(
'Cache-Control')
120 ->will($this->returnValue($header));
122 ->expects($this->once())
124 ->with($this->responseMock);
127 $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock)
137 ->expects($this->once())
140 $this->configMock->expects($this->once())
141 ->method(
'isEnabled')
142 ->will($this->returnValue(
true));
144 ->expects($this->once())
147 ->expects($this->once())
149 ->will($this->returnValue(
false));
150 $this->stateMock->expects($this->any())
152 ->will($this->returnValue($state));
154 $result = $this->createMock(\
Magento\Framework\Controller\ResultInterface::class);
155 $result->expects($this->never())->method(
'setHeader');
162 $this->plugin->aroundDispatch($this->frontControllerMock,
$closure, $this->requestMock)
172 ->expects($this->once())
175 $this->configMock->expects($this->once())
176 ->method(
'isEnabled')
177 ->will($this->returnValue(
true));
179 ->expects($this->once())
182 ->expects($this->once())
184 ->will($this->returnValue($this->responseMock));
186 $this->stateMock->expects($this->any())
188 ->will($this->returnValue($state));
189 if ($state == \
Magento\Framework\
App\State::MODE_DEVELOPER) {
190 $this->responseMock->expects($this->once())
191 ->method(
'setHeader')
192 ->with(
'X-Magento-Cache-Debug');
194 $this->responseMock->expects($this->never())
195 ->method(
'setHeader');
199 $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock)
209 ->expects($this->any())
211 ->will($this->returnValue(
null));
212 $this->configMock->expects($this->any())
213 ->method(
'isEnabled')
214 ->will($this->returnValue(
true));
216 ->expects($this->once())
218 $this->stateMock->expects($this->any())
220 ->will($this->returnValue($state));
221 $this->responseMock->expects($this->never())
222 ->method(
'setHeader');
225 $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock)
testAroundDispatchReturnsCache($state)
testAroundDispatchReturnsResultInterfaceProcessIfCacheMissed($state)
testAroundDispatchProcessIfCacheMissed($state)
testAroundDispatchDisabled($state)