Skip to content

Commit e4554f4

Browse files
digitalrisedorsetglo63652
authored andcommitted
Added missing dependency to unit test to get the tests to pass
1 parent e72e6a3 commit e4554f4

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Request\Http as HttpRequest;
1313
use Magento\Framework\Serialize\Serializer\Json;
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
15+
use Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718

@@ -46,6 +47,10 @@ class IdentifierTest extends TestCase
4647
* @var Json|MockObject
4748
*/
4849
private $serializerMock;
50+
/**
51+
* @var IdentifierStoreReader|MockObject
52+
*/
53+
private $identifierStoreReader;
4954

5055
/**
5156
* @inheritdoc
@@ -73,12 +78,19 @@ function ($value) {
7378
}
7479
);
7580

81+
$this->identifierStoreReader = $this->getMockBuilder(IdentifierStoreReader::class)
82+
->onlyMethods(['getPageTagsWithStoreCacheTags'])
83+
->disableOriginalConstructor()
84+
->getMock();
85+
86+
7687
$this->model = $this->objectManager->getObject(
7788
Identifier::class,
7889
[
7990
'request' => $this->requestMock,
8091
'context' => $this->contextMock,
81-
'serializer' => $this->serializerMock
92+
'serializer' => $this->serializerMock,
93+
'identifierStoreReader' => $this->identifierStoreReader
8294
]
8395
);
8496
parent::setUp();
@@ -96,6 +108,12 @@ public function testSecureDifferentiator(): void
96108
->willReturn('http://example.com/path/');
97109
$this->contextMock->method('getVaryString')->willReturn(self::VARY);
98110

111+
$this->identifierStoreReader->method('getPageTagsWithStoreCacheTags')->willReturnCallback(
112+
function ($value) {
113+
return $value;
114+
}
115+
);
116+
99117
$valueWithSecureRequest = $this->model->getValue();
100118
$valueWithInsecureRequest = $this->model->getValue();
101119
$this->assertNotEquals($valueWithSecureRequest, $valueWithInsecureRequest);
@@ -112,6 +130,12 @@ public function testDomainDifferentiator(): void
112130
->willReturnOnConsecutiveCalls('http://example.com/path/', 'http://example.net/path/');
113131
$this->contextMock->method('getVaryString')->willReturn(self::VARY);
114132

133+
$this->identifierStoreReader->method('getPageTagsWithStoreCacheTags')->willReturnCallback(
134+
function ($value) {
135+
return $value;
136+
}
137+
);
138+
115139
$valueDomain1 = $this->model->getValue();
116140
$valueDomain2 = $this->model->getValue();
117141
$this->assertNotEquals($valueDomain1, $valueDomain2);
@@ -128,6 +152,12 @@ public function testPathDifferentiator(): void
128152
->willReturnOnConsecutiveCalls('http://example.com/path/', 'http://example.com/path1/');
129153
$this->contextMock->method('getVaryString')->willReturn(self::VARY);
130154

155+
$this->identifierStoreReader->method('getPageTagsWithStoreCacheTags')->willReturnCallback(
156+
function ($value) {
157+
return $value;
158+
}
159+
);
160+
131161
$valuePath1 = $this->model->getValue();
132162
$valuePath2 = $this->model->getValue();
133163
$this->assertNotEquals($valuePath1, $valuePath2);
@@ -173,6 +203,12 @@ public function testGetValue(): void
173203
->method('getVaryString')
174204
->willReturn(self::VARY);
175205

206+
$this->identifierStoreReader->method('getPageTagsWithStoreCacheTags')->willReturnCallback(
207+
function ($value) {
208+
return $value;
209+
}
210+
);
211+
176212
$this->assertEquals(
177213
sha1(
178214
json_encode(

0 commit comments

Comments
 (0)