12
12
use Magento \Framework \App \Request \Http as HttpRequest ;
13
13
use Magento \Framework \Serialize \Serializer \Json ;
14
14
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
15
+ use Magento \PageCache \Model \App \Request \Http \IdentifierStoreReader ;
15
16
use PHPUnit \Framework \MockObject \MockObject ;
16
17
use PHPUnit \Framework \TestCase ;
17
18
@@ -46,6 +47,10 @@ class IdentifierTest extends TestCase
46
47
* @var Json|MockObject
47
48
*/
48
49
private $ serializerMock ;
50
+ /**
51
+ * @var IdentifierStoreReader|MockObject
52
+ */
53
+ private $ identifierStoreReader ;
49
54
50
55
/**
51
56
* @inheritdoc
@@ -73,12 +78,19 @@ function ($value) {
73
78
}
74
79
);
75
80
81
+ $ this ->identifierStoreReader = $ this ->getMockBuilder (IdentifierStoreReader::class)
82
+ ->onlyMethods (['getPageTagsWithStoreCacheTags ' ])
83
+ ->disableOriginalConstructor ()
84
+ ->getMock ();
85
+
86
+
76
87
$ this ->model = $ this ->objectManager ->getObject (
77
88
Identifier::class,
78
89
[
79
90
'request ' => $ this ->requestMock ,
80
91
'context ' => $ this ->contextMock ,
81
- 'serializer ' => $ this ->serializerMock
92
+ 'serializer ' => $ this ->serializerMock ,
93
+ 'identifierStoreReader ' => $ this ->identifierStoreReader
82
94
]
83
95
);
84
96
parent ::setUp ();
@@ -96,6 +108,12 @@ public function testSecureDifferentiator(): void
96
108
->willReturn ('http://example.com/path/ ' );
97
109
$ this ->contextMock ->method ('getVaryString ' )->willReturn (self ::VARY );
98
110
111
+ $ this ->identifierStoreReader ->method ('getPageTagsWithStoreCacheTags ' )->willReturnCallback (
112
+ function ($ value ) {
113
+ return $ value ;
114
+ }
115
+ );
116
+
99
117
$ valueWithSecureRequest = $ this ->model ->getValue ();
100
118
$ valueWithInsecureRequest = $ this ->model ->getValue ();
101
119
$ this ->assertNotEquals ($ valueWithSecureRequest , $ valueWithInsecureRequest );
@@ -112,6 +130,12 @@ public function testDomainDifferentiator(): void
112
130
->willReturnOnConsecutiveCalls ('http://example.com/path/ ' , 'http://example.net/path/ ' );
113
131
$ this ->contextMock ->method ('getVaryString ' )->willReturn (self ::VARY );
114
132
133
+ $ this ->identifierStoreReader ->method ('getPageTagsWithStoreCacheTags ' )->willReturnCallback (
134
+ function ($ value ) {
135
+ return $ value ;
136
+ }
137
+ );
138
+
115
139
$ valueDomain1 = $ this ->model ->getValue ();
116
140
$ valueDomain2 = $ this ->model ->getValue ();
117
141
$ this ->assertNotEquals ($ valueDomain1 , $ valueDomain2 );
@@ -128,6 +152,12 @@ public function testPathDifferentiator(): void
128
152
->willReturnOnConsecutiveCalls ('http://example.com/path/ ' , 'http://example.com/path1/ ' );
129
153
$ this ->contextMock ->method ('getVaryString ' )->willReturn (self ::VARY );
130
154
155
+ $ this ->identifierStoreReader ->method ('getPageTagsWithStoreCacheTags ' )->willReturnCallback (
156
+ function ($ value ) {
157
+ return $ value ;
158
+ }
159
+ );
160
+
131
161
$ valuePath1 = $ this ->model ->getValue ();
132
162
$ valuePath2 = $ this ->model ->getValue ();
133
163
$ this ->assertNotEquals ($ valuePath1 , $ valuePath2 );
@@ -173,6 +203,12 @@ public function testGetValue(): void
173
203
->method ('getVaryString ' )
174
204
->willReturn (self ::VARY );
175
205
206
+ $ this ->identifierStoreReader ->method ('getPageTagsWithStoreCacheTags ' )->willReturnCallback (
207
+ function ($ value ) {
208
+ return $ value ;
209
+ }
210
+ );
211
+
176
212
$ this ->assertEquals (
177
213
sha1 (
178
214
json_encode (
0 commit comments