16 use Zend\Http\Header\HeaderInterface as HttpHeaderInterface;
32 private $objectManagerHelper;
52 private $registryMock;
62 private $responseMock;
67 private $httpHeaderMock;
71 $this->configMock = $this->getMockBuilder(Config::class)
72 ->disableOriginalConstructor()
74 $this->kernelMock = $this->getMockBuilder(Kernel::class)
75 ->disableOriginalConstructor()
77 $this->stateMock = $this->getMockBuilder(AppState::class)
78 ->disableOriginalConstructor()
80 $this->registryMock = $this->getMockBuilder(Registry::class)
81 ->disableOriginalConstructor()
83 $this->resultMock = $this->getMockBuilder(ResultInterface::class)
84 ->getMockForAbstractClass();
85 $this->responseMock = $this->getMockBuilder(ResponseHttp::class)
86 ->disableOriginalConstructor()
88 $this->httpHeaderMock = $this->getMockBuilder(HttpHeaderInterface::class)
89 ->getMockForAbstractClass();
91 $this->responseMock->expects(static::any())
95 [
'X-Magento-Tags', $this->httpHeaderMock],
96 [
'Cache-Control', $this->httpHeaderMock]
99 $this->configMock->expects(static::any())
100 ->method(
'isEnabled')
102 $this->configMock->expects(static::any())
106 $this->objectManagerHelper =
new ObjectManagerHelper($this);
107 $this->plugin = $this->objectManagerHelper->getObject(
108 BuiltinPlugin::class,
110 'registry' => $this->registryMock,
111 'config' => $this->configMock,
112 'kernel' => $this->kernelMock,
113 'state' => $this->stateMock
120 $this->registryMock->expects(static::once())
122 ->with(
'use_page_cache_plugin')
124 $this->kernelMock->expects(static::never())
126 ->with($this->responseMock);
130 $this->plugin->afterRenderResult($this->resultMock, $this->resultMock, $this->responseMock)
136 $this->registryMock->expects(static::once())
138 ->with(
'use_page_cache_plugin')
140 $this->stateMock->expects(static::once())
143 $this->httpHeaderMock->expects(static::any())
144 ->method(
'getFieldValue')
145 ->willReturn(
'tag,tag');
146 $this->responseMock->expects(static::once())
147 ->method(
'clearHeader')
148 ->with(
'X-Magento-Tags');
149 $this->responseMock->expects(static::once())
150 ->method(
'setHeader')
151 ->with(
'X-Magento-Tags',
'tag,' . CacheType::CACHE_TAG);
152 $this->kernelMock->expects(static::once())
154 ->with($this->responseMock);
158 $this->plugin->afterRenderResult($this->resultMock, $this->resultMock, $this->responseMock)
164 $this->registryMock->expects(static::once())
166 ->with(
'use_page_cache_plugin')
168 $this->stateMock->expects(static::once())
170 ->willReturn(AppState::MODE_DEVELOPER);
171 $this->httpHeaderMock->expects(static::any())
172 ->method(
'getFieldValue')
173 ->willReturnOnConsecutiveCalls(
'test',
'tag,tag2');
174 $this->responseMock->expects(static::any())
175 ->method(
'setHeader')
177 [
'X-Magento-Cache-Control',
'test'],
178 [
'X-Magento-Cache-Debug',
'MISS',
true],
179 [
'X-Magento-Tags',
'tag,tag2,' . CacheType::CACHE_TAG]
181 $this->responseMock->expects(static::once())
182 ->method(
'clearHeader')
183 ->with(
'X-Magento-Tags');
184 $this->registryMock->expects(static::once())
186 ->with(
'use_page_cache_plugin')
188 $this->kernelMock->expects(static::once())
190 ->with($this->responseMock);
194 $this->plugin->afterRenderResult($this->resultMock, $this->resultMock, $this->responseMock)
testAfterResultWithoutPlugin()
testAfterResultWithPlugin()
testAfterResultWithPluginDeveloperMode()