@@ -122,6 +122,40 @@ protected function setUp()
122
122
123
123
$ this ->moduleReader = $ this ->getMock (\Magento \Framework \Module \Dir \Reader::class, [], [], '' , false );
124
124
$ 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
+ )));
125
159
$ this ->config = $ objectManager ->getObject (
126
160
\Magento \PageCache \Model \Config::class,
127
161
[
@@ -130,6 +164,7 @@ protected function setUp()
130
164
'cacheState ' => $ this ->cacheState ,
131
165
'reader ' => $ this ->moduleReader ,
132
166
'serializer ' => $ this ->serializerMock ,
167
+ 'vclGeneratorFactory ' => $ vclGeneratorFactory
133
168
]
134
169
);
135
170
}
@@ -139,9 +174,6 @@ protected function setUp()
139
174
*/
140
175
public function testGetVcl ()
141
176
{
142
- $ this ->moduleReader ->expects ($ this ->once ())
143
- ->method ('getModuleDir ' )
144
- ->willReturn ('/magento/app/code/Magento/PageCache ' );
145
177
$ this ->serializerMock ->expects ($ this ->once ())
146
178
->method ('unserialize ' )
147
179
->with ('serializedConfig ' )
0 commit comments