Skip to content

Commit a80d026

Browse files
committed
add unit test
1 parent d3df409 commit a80d026

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

app/code/Magento/PageCache/Test/Unit/Model/App/Request/Http/IdentifierForSaveTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,43 @@ function ($value) {
121121
$this->model->getValue()
122122
);
123123
}
124+
125+
/**
126+
* Test get identifier for save value with marketing parameters.
127+
*
128+
* @return void
129+
*/
130+
public function testGetValueWithMarketingParameters(): void
131+
{
132+
$this->requestMock->expects($this->any())
133+
->method('isSecure')
134+
->willReturn(true);
135+
136+
$this->requestMock->expects($this->any())
137+
->method('getUriString')
138+
->willReturn('http://example.com/path1/?abc=123&gclid=456&utm_source=abc');
139+
140+
$this->contextMock->expects($this->any())
141+
->method('getVaryString')
142+
->willReturn(self::VARY);
143+
144+
$this->identifierStoreReader->method('getPageTagsWithStoreCacheTags')->willReturnCallback(
145+
function ($value) {
146+
return $value;
147+
}
148+
);
149+
150+
$this->assertEquals(
151+
sha1(
152+
json_encode(
153+
[
154+
true,
155+
'http://example.com/path1/?abc=123',
156+
self::VARY
157+
]
158+
)
159+
),
160+
$this->model->getValue()
161+
);
162+
}
124163
}

lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,37 @@ public function testGetValue(): void
186186
$this->model->getValue()
187187
);
188188
}
189+
190+
/**
191+
* Test get identifier value with marketing parameters.
192+
*
193+
* @return void
194+
*/
195+
public function testGetValueWithMarketingParameters(): void
196+
{
197+
$this->requestMock->expects($this->any())
198+
->method('isSecure')
199+
->willReturn(true);
200+
201+
$this->requestMock->expects($this->any())
202+
->method('getUriString')
203+
->willReturn('http://example.com/path1/?abc=123&gclid=456&utm_source=abc');
204+
205+
$this->contextMock->expects($this->any())
206+
->method('getVaryString')
207+
->willReturn(self::VARY);
208+
209+
$this->assertEquals(
210+
sha1(
211+
json_encode(
212+
[
213+
true,
214+
'http://example.com/path1/?abc=123',
215+
self::VARY
216+
]
217+
)
218+
),
219+
$this->model->getValue()
220+
);
221+
}
189222
}

0 commit comments

Comments
 (0)