26 private $coreConfigMock;
36 private $moduleReader;
41 private $serializerMock;
46 protected function setUp()
49 $readFactoryMock = $this->createMock(\
Magento\Framework\Filesystem\Directory\ReadFactory::class);
50 $this->coreConfigMock = $this->createMock(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class);
51 $this->cacheState = $this->getMockForAbstractClass(\
Magento\Framework\
App\Cache\StateInterface::class);
53 $modulesDirectoryMock = $this->createMock(\
Magento\Framework\Filesystem\Directory\Write::class);
54 $readFactoryMock->expects(
59 $this->returnValue($modulesDirectoryMock)
61 $modulesDirectoryMock->expects(
68 $this->coreConfigMock->expects(
73 $this->returnValueMap(
91 '127.0.0.1, 192.168.0.1,127.0.0.2' 95 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
100 \
Magento\Framework\HTTP\PhpEnvironment\Request::XML_PATH_OFFLOADER_HEADER,
103 'X_Forwarded_Proto: https' 115 $this->moduleReader = $this->createMock(\
Magento\Framework\Module\Dir\Reader::class);
116 $this->serializerMock = $this->createMock(Json::class);
119 $vclTemplateLocator = $this->getMockBuilder(\
Magento\PageCache\Model\Varnish\VclTemplateLocator::class)
120 ->disableOriginalConstructor()
121 ->setMethods([
'getTemplate'])
123 $vclTemplateLocator->expects($this->any())
124 ->method(
'getTemplate')
127 $vclGeneratorFactory = $this->getMockBuilder(\
Magento\PageCache\Model\Varnish\VclGeneratorFactory::class)
128 ->disableOriginalConstructor()
129 ->setMethods([
'create'])
132 'backendHost' =>
'example.com',
133 'backendPort' =>
'8080',
134 'accessList' => explode(
',',
'127.0.0.1, 192.168.0.1,127.0.0.2'),
135 'designExceptions' => [[
'regexp' =>
'(?i)pattern',
'value' =>
'value_for_pattern']],
136 'sslOffloadedHeader' =>
'X_Forwarded_Proto: https',
139 $vclGeneratorFactory->expects($this->any())
141 ->with($expectedParams)
142 ->will($this->returnValue(
new \
Magento\PageCache\Model\Varnish\VclGenerator(
146 explode(
',',
'127.0.0.1,192.168.0.1,127.0.0.2'),
148 'X_Forwarded_Proto: https',
149 [[
'regexp' =>
'(?i)pattern',
'value' =>
'value_for_pattern']]
152 \
Magento\PageCache\Model\Config::class,
154 'readFactory' => $readFactoryMock,
155 'scopeConfig' => $this->coreConfigMock,
156 'cacheState' => $this->cacheState,
157 'reader' => $this->moduleReader,
158 'serializer' => $this->serializerMock,
159 'vclGeneratorFactory' => $vclGeneratorFactory
169 $this->serializerMock->expects($this->once())
170 ->method(
'unserialize')
171 ->with(
'serializedConfig')
172 ->willReturn([[
'regexp' =>
'(?i)pattern',
'value' =>
'value_for_pattern']]);
180 $this->config->getTtl();
188 $this->cacheState->expects($this->at(0))
189 ->method(
'isEnabled')
190 ->with(\
Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER)
191 ->will($this->returnValue(
true));
192 $this->cacheState->expects($this->at(1))
193 ->method(
'isEnabled')
194 ->with(\
Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER)
195 ->will($this->returnValue(
false));
196 $this->assertTrue($this->config->isEnabled());
197 $this->assertFalse($this->config->isEnabled());
const VARNISH_5_CONFIGURATION_PATH
defined('TESTS_BP')||define('TESTS_BP' __DIR__
const XML_VARNISH_PAGECACHE_BACKEND_HOST
const XML_VARNISH_PAGECACHE_BACKEND_PORT
const XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX
const XML_VARNISH_PAGECACHE_ACCESS_LIST
const XML_VARNISH_PAGECACHE_GRACE_PERIOD