Skip to content

Commit b91f7af

Browse files
committed
AC-12715::Investigate the laminas composer dependencies upgrading to latest version
1 parent 486cbf1 commit b91f7af

File tree

1 file changed

+27
-35
lines changed
  • dev/tests/integration/testsuite/Magento/GraphQlResolverCache/Model/Plugin/Resolver

1 file changed

+27
-35
lines changed

dev/tests/integration/testsuite/Magento/GraphQlResolverCache/Model/Plugin/Resolver/CacheTest.php

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,29 @@ class CacheTest extends TestCase
6969
/**
7070
* @inheritdoc
7171
*/
72-
public function setUp(): void
72+
protected function setUp(): void
7373
{
7474
$this->objectManager = Bootstrap::getObjectManager();
7575
$this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
7676
$this->cacheState = $this->objectManager->get(CacheState::class);
7777
$this->origCacheEnabled = $this->cacheState->isEnabled(Type::TYPE_IDENTIFIER);
78+
7879
if (!$this->origCacheEnabled) {
7980
$this->cacheState->setEnabled(Type::TYPE_IDENTIFIER, true);
8081
$this->cacheState->persist();
8182
}
83+
8284
$this->graphQlResolverCache = $this->objectManager->get(Type::class);
8385
$this->graphQlResolverCache->clean();
86+
87+
$this->preconfigureMocks();
88+
$this->configurePlugin();
8489
}
8590

8691
/**
8792
* @inheritdoc
8893
*/
89-
public function tearDown(): void
94+
protected function tearDown(): void
9095
{
9196
$this->cacheState->setEnabled(Type::TYPE_IDENTIFIER, $this->origCacheEnabled);
9297
$this->cacheState->persist();
@@ -97,33 +102,36 @@ public function tearDown(): void
97102
/**
98103
* @magentoAppArea graphql
99104
*/
100-
public function testCachingSkippedOnKeyCalculationFailure()
105+
public function testCachingSkippedOnKeyCalculationFailure(): void
101106
{
102-
$this->preconfigureMocks();
103-
$this->configurePlugin();
104107
$this->keyFactorMock->expects($this->any())
105108
->method('getFactorValue')
106109
->willThrowException(new \Exception("Test key factor exception"));
110+
107111
$this->graphqlResolverCacheMock->expects($this->never())
108112
->method('load');
113+
109114
$this->graphqlResolverCacheMock->expects($this->never())
110115
->method('save');
116+
111117
$this->graphQlRequest->send($this->getTestQuery());
112118
}
113119

114120
/**
115121
* @magentoAppArea graphql
116122
*/
117-
public function testCachingNotSkippedWhenKeysOk()
123+
public function testCachingNotSkippedWhenKeysOk(): void
118124
{
119-
$this->preconfigureMocks();
120-
$this->configurePlugin();
121-
$this->loggerMock->expects($this->never())->method('warning');
125+
$this->loggerMock->expects($this->never())
126+
->method('warning');
127+
122128
$this->graphqlResolverCacheMock->expects($this->once())
123129
->method('load')
124130
->willReturn(false);
131+
125132
$this->graphqlResolverCacheMock->expects($this->once())
126133
->method('save');
134+
127135
$this->graphQlRequest->send($this->getTestQuery());
128136
}
129137

@@ -132,25 +140,13 @@ public function testCachingNotSkippedWhenKeysOk()
132140
*
133141
* @return void
134142
*/
135-
private function preconfigureMocks()
143+
private function preconfigureMocks(): void
136144
{
137-
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
138-
->disableOriginalConstructor()
139-
->onlyMethods(['warning'])
140-
->setMockClassName('CacheLoggerMockForTest')
141-
->getMockForAbstractClass();
142-
143-
$this->graphqlResolverCacheMock = $this->getMockBuilder(Type::class)
144-
->disableOriginalConstructor()
145-
->onlyMethods(['load', 'save'])
146-
->setMockClassName('GraphqlResolverCacheMockForTest')
147-
->getMock();
148-
149-
$this->keyFactorMock = $this->getMockBuilder(GenericFactorProviderInterface::class)
150-
->disableOriginalConstructor()
151-
->onlyMethods(['getFactorValue', 'getFactorName'])
152-
->setMockClassName('TestFailingKeyFactor')
153-
->getMock();
145+
$this->loggerMock = $this->createMock(LoggerInterface::class);
146+
147+
$this->graphqlResolverCacheMock = $this->createMock(Type::class);
148+
149+
$this->keyFactorMock = $this->createMock(GenericFactorProviderInterface::class);
154150

155151
$this->objectManager->addSharedInstance($this->keyFactorMock, 'TestFailingKeyFactor');
156152

@@ -180,12 +176,7 @@ private function preconfigureMocks()
180176
]
181177
);
182178

183-
$identityProviderMock = $this->getMockBuilder(IdentityInterface::class)
184-
->disableOriginalConstructor()
185-
->onlyMethods(['getIdentities'])
186-
->setMockClassName('TestIdentityProvider')
187-
->getMock();
188-
179+
$identityProviderMock = $this->createMock(IdentityInterface::class);
189180
$identityProviderMock->expects($this->any())
190181
->method('getIdentities')
191182
->willReturn(['test_identity']);
@@ -205,7 +196,7 @@ private function preconfigureMocks()
205196
);
206197
}
207198

208-
private function getTestQuery()
199+
private function getTestQuery(): string
209200
{
210201
return <<<QUERY
211202
{
@@ -224,12 +215,13 @@ private function getTestQuery()
224215
*
225216
* @return void
226217
*/
227-
private function configurePlugin()
218+
private function configurePlugin(): void
228219
{
229220
// need to reset plugins list to inject new plugin with mocks as it is cached at runtime
230221
/** @var PluginList $pluginList */
231222
$pluginList = $this->objectManager->get(PluginList::class);
232223
$pluginList->reset();
224+
233225
$this->objectManager->removeSharedInstance(CachePlugin::class);
234226
$this->objectManager->addSharedInstance(
235227
$this->objectManager->create(CachePlugin::class, [

0 commit comments

Comments
 (0)