Skip to content

Commit b004f72

Browse files
committed
MAGETWO-67537: [WIP] Varnish Vcl generator command #9286
- fixed static and integration tests
1 parent 6029a4a commit b004f72

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

app/code/Magento/PageCache/Test/Unit/Model/ConfigTest.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ protected function setUp()
122122

123123
$this->moduleReader = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false);
124124
$this->serializerMock = $this->getMock(Json::class, [], [], '', false);
125+
126+
/** @var \PHPUnit_Framework_MockObject_MockObject $vclTemplateLocator */
127+
$vclTemplateLocator = $this->getMockBuilder(\Magento\PageCache\Model\Varnish\VclTemplateLocator::class)
128+
->disableOriginalConstructor()
129+
->setMethods(['getTemplate'])
130+
->getMock();
131+
$vclTemplateLocator->expects($this->any())
132+
->method('getTemplate')
133+
->will($this->returnValue(file_get_contents(__DIR__ . '/_files/test.vcl')));
134+
/** @var \PHPUnit_Framework_MockObject_MockObject $vclTemplateLocator */
135+
$vclGeneratorFactory = $this->getMockBuilder(\Magento\PageCache\Model\Varnish\VclGeneratorFactory::class)
136+
->disableOriginalConstructor()
137+
->setMethods(['create'])
138+
->getMock();
139+
$expectedParams = [
140+
'backendHost' => 'example.com',
141+
'backendPort' => '8080',
142+
'accessList' => explode(',', '127.0.0.1, 192.168.0.1,127.0.0.2'),
143+
'designExceptions' => [['regexp' => '(?i)pattern', 'value' => 'value_for_pattern']],
144+
'sslOffloadedHeader' => 'X_Forwarded_Proto: https',
145+
'gracePeriod' => 120
146+
];
147+
$vclGeneratorFactory->expects($this->any())
148+
->method('create')
149+
->with($expectedParams)
150+
->will($this->returnValue(new \Magento\PageCache\Model\Varnish\VclGenerator(
151+
$vclTemplateLocator,
152+
'example.com',
153+
'8080',
154+
explode(',', '127.0.0.1,192.168.0.1,127.0.0.2'),
155+
120,
156+
'X_Forwarded_Proto: https',
157+
[['regexp' => '(?i)pattern', 'value' => 'value_for_pattern']]
158+
)));
125159
$this->config = $objectManager->getObject(
126160
\Magento\PageCache\Model\Config::class,
127161
[
@@ -130,6 +164,7 @@ protected function setUp()
130164
'cacheState' => $this->cacheState,
131165
'reader' => $this->moduleReader,
132166
'serializer' => $this->serializerMock,
167+
'vclGeneratorFactory' => $vclGeneratorFactory
133168
]
134169
);
135170
}
@@ -139,9 +174,6 @@ protected function setUp()
139174
*/
140175
public function testGetVcl()
141176
{
142-
$this->moduleReader->expects($this->once())
143-
->method('getModuleDir')
144-
->willReturn('/magento/app/code/Magento/PageCache');
145177
$this->serializerMock->expects($this->once())
146178
->method('unserialize')
147179
->with('serializedConfig')

0 commit comments

Comments
 (0)