@@ -42,6 +42,7 @@ protected function setUp()
42
42
'cacheServer ' => $ this ->cacheServer ,
43
43
'socketAdapterFactory ' => $ socketFactoryMock ,
44
44
'logger ' => $ this ->loggerMock ,
45
+ 'maxHeaderSize ' => 256
45
46
]
46
47
);
47
48
}
@@ -85,6 +86,49 @@ public function testSendPurgeRequest($hosts)
85
86
$ this ->assertTrue ($ this ->model ->sendPurgeRequest (['tags ' ]));
86
87
}
87
88
89
+ public function testSendMultiPurgeRequest ()
90
+ {
91
+ $ tags = [
92
+ '(^|,)cat_p_95(,|$) ' , '(^|,)cat_p_96(,|$) ' , '(^|,)cat_p_97(,|$) ' , '(^|,)cat_p_98(,|$) ' ,
93
+ '(^|,)cat_p_99(,|$) ' , '(^|,)cat_p_100(,|$) ' , '(^|,)cat_p_10038(,|$) ' , '(^|,)cat_p_142985(,|$) ' ,
94
+ '(^|,)cat_p_199(,|$) ' , '(^|,)cat_p_300(,|$) ' , '(^|,)cat_p_12038(,|$) ' , '(^|,)cat_p_152985(,|$) ' ,
95
+ '(^|,)cat_p_299(,|$) ' , '(^|,)cat_p_400(,|$) ' , '(^|,)cat_p_13038(,|$) ' , '(^|,)cat_p_162985(,|$) ' ,
96
+ ];
97
+
98
+ $ tagsSplitA = array_slice ($ tags , 0 , 12 );
99
+ $ tagsSplitB = array_slice ($ tags , 12 , 4 );
100
+
101
+ $ uri = UriFactory::factory ('' )->setHost ('localhost ' )
102
+ ->setPort (80 )
103
+ ->setScheme ('http ' );
104
+
105
+ $ this ->cacheServer ->expects ($ this ->once ())
106
+ ->method ('getUris ' )
107
+ ->willReturn ([$ uri ]);
108
+
109
+ $ this ->socketAdapterMock ->expects ($ this ->exactly (2 ))
110
+ ->method ('connect ' )
111
+ ->with ($ uri ->getHost (), $ uri ->getPort ());
112
+
113
+ $ this ->socketAdapterMock ->expects ($ this ->exactly (2 ))
114
+ ->method ('write ' )
115
+ ->withConsecutive (
116
+ [
117
+ 'PURGE ' , $ uri , '1.1 ' ,
118
+ ['X-Magento-Tags-Pattern ' => implode ('| ' , $ tagsSplitA ), 'Host ' => $ uri ->getHost ()]
119
+ ],
120
+ [
121
+ 'PURGE ' , $ uri , '1.1 ' ,
122
+ ['X-Magento-Tags-Pattern ' => implode ('| ' , $ tagsSplitB ), 'Host ' => $ uri ->getHost ()]
123
+ ]
124
+ );
125
+
126
+ $ this ->socketAdapterMock ->expects ($ this ->exactly (2 ))
127
+ ->method ('close ' );
128
+
129
+ $ this ->assertTrue ($ this ->model ->sendPurgeRequest ($ tags ));
130
+ }
131
+
88
132
/**
89
133
* @return array
90
134
*/
0 commit comments