Skip to content

Commit 39d4f75

Browse files
committed
39099: fix failed unit test and remove extra line
1 parent 4fbd604 commit 39d4f75

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
namespace Magento\PageCache\Test\Unit\Model\App\Request\Http;
99

1010
use Magento\Framework\App\Http\Context;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\App\PageCache\Identifier;
1113
use Magento\Framework\App\Request\Http as HttpRequest;
14+
use Magento\Framework\ObjectManagerInterface;
1215
use Magento\Framework\Serialize\Serializer\Json;
1316
use Magento\PageCache\Model\App\Request\Http\IdentifierForSave;
1417
use Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader;
@@ -46,6 +49,11 @@ class IdentifierForSaveTest extends TestCase
4649
*/
4750
private $identifierStoreReader;
4851

52+
/**
53+
* @var Identifier
54+
*/
55+
private $identifierMock;
56+
4957
/**
5058
* @inheritdoc
5159
*/
@@ -74,6 +82,16 @@ function ($value) {
7482
->disableOriginalConstructor()
7583
->getMock();
7684

85+
$this->identifierMock = $this->getMockBuilder(Identifier::class)
86+
->disableOriginalConstructor()
87+
->getMock();
88+
89+
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
90+
$objectManagerMock->expects($this->once())
91+
->method('get')
92+
->willReturn($this->identifierMock);
93+
ObjectManager::setInstance($objectManagerMock);
94+
7795
$this->model = new IdentifierForSave(
7896
$this->requestMock,
7997
$this->contextMock,
@@ -90,6 +108,10 @@ function ($value) {
90108
*/
91109
public function testGetValue(): void
92110
{
111+
$this->identifierMock->expects($this->once())
112+
->method('getMarketingParameterPatterns')
113+
->willReturn($this->getpattern());
114+
93115
$this->requestMock->expects($this->any())
94116
->method('isSecure')
95117
->willReturn(true);
@@ -129,6 +151,10 @@ function ($value) {
129151
*/
130152
public function testGetValueWithMarketingParameters(): void
131153
{
154+
$this->identifierMock->expects($this->any())
155+
->method('getMarketingParameterPatterns')
156+
->willReturn($this->getPattern());
157+
132158
$this->requestMock->expects($this->any())
133159
->method('isSecure')
134160
->willReturn(true);
@@ -160,4 +186,33 @@ function ($value) {
160186
$this->model->getValue()
161187
);
162188
}
189+
190+
/**
191+
* @return string[]
192+
*/
193+
public function getPattern(): array
194+
{
195+
return [
196+
'/&?gad_source\=[^&]+/',
197+
'/&?gbraid\=[^&]+/',
198+
'/&?wbraid\=[^&]+/',
199+
'/&?_gl\=[^&]+/',
200+
'/&?dclid\=[^&]+/',
201+
'/&?gclsrc\=[^&]+/',
202+
'/&?srsltid\=[^&]+/',
203+
'/&?msclkid\=[^&]+/',
204+
'/&?_kx\=[^&]+/',
205+
'/&?gclid\=[^&]+/',
206+
'/&?cx\=[^&]+/',
207+
'/&?ie\=[^&]+/',
208+
'/&?cof\=[^&]+/',
209+
'/&?siteurl\=[^&]+/',
210+
'/&?zanpid\=[^&]+/',
211+
'/&?origin\=[^&]+/',
212+
'/&?fbclid\=[^&]+/',
213+
'/&?mc_(.*?)\=[^&]+/',
214+
'/&?utm_(.*?)\=[^&]+/',
215+
'/&?_bta_(.*?)\=[^&]+/',
216+
];
217+
}
163218
}

lib/internal/Magento/Framework/App/PageCache/Identifier.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public function getValue()
6565
/**
6666
* Pattern detect marketing parameters
6767
*
68-
*
6968
* @return array
7069
*/
7170
public function getMarketingParameterPatterns(): array

0 commit comments

Comments
 (0)