Skip to content

Commit 9b0f8f4

Browse files
committed
MAGE-1385 Remove implicit nullable and modify unit tests to support both PHPUnit 9 and 10
1 parent ae7a89c commit 9b0f8f4

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

Plugin/Cache/CacheCleanProductPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function hasEnablementChanged(array $orig, array $new): bool
7777
return $orig[$key] !== $new[$key];
7878
}
7979

80-
protected function hasVisibilityChanged(array $orig, array $new, int $storeId = null): bool
80+
protected function hasVisibilityChanged(array $orig, array $new, ?int $storeId = null): bool
8181
{
8282
if ($this->configHelper->includeNonVisibleProductsInIndex($storeId)) {
8383
return false;

Test/Unit/Service/Product/BatchQueueProcessorTest.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,19 @@ public function testProcessBatchHandlesDeltaIndexingPaged()
112112
$this->setupBasicIndexingConfig($pageSize);
113113
$this->productHelper->method('getParentProductIds')->willReturn([]);
114114

115-
$invocations = $this->exactly(5);
116-
$this->queue->expects($invocations)
115+
$invocationCount = 0;
116+
$this->queue->expects($this->exactly(5))
117117
->method('addToQueue')
118118
->with(
119119
IndexBuilder::class,
120120
'buildIndexList',
121-
$this->callback(function(array $arg) use ($invocations, $pageSize) {
121+
$this->callback(function(array $arg) use (&$invocationCount, $pageSize) {
122+
$invocationCount++;
122123
return array_key_exists('storeId', $arg)
123124
&& array_key_exists('entityIds', $arg)
124125
&& array_key_exists('options', $arg)
125126
&& $arg['options']['pageSize'] === $pageSize
126-
&& $arg['options']['page'] === $invocations->getInvocationCount();
127+
&& $arg['options']['page'] === $invocationCount;
127128
})
128129
);
129130

@@ -142,8 +143,8 @@ public function testProcessBatchHandlesFullIndexing()
142143
$this->productHelper->method('getProductCollectionQuery')->willReturn($this->getMockCollection());
143144
$this->queueHelper->method('useTmpIndex')->willReturn(false);
144145

145-
$invocations = $this->exactly(2);
146-
$this->queue->expects($invocations)
146+
$invocationCount = 0;
147+
$this->queue->expects($this->exactly(2))
147148
->method('addToQueue')
148149
->willReturnCallback(
149150
function(
@@ -152,8 +153,9 @@ function(
152153
array $data,
153154
int $dataSize,
154155
bool $isFullReindex)
155-
use ($invocations) {
156-
switch ($invocations->getInvocationCount()) {
156+
use (&$invocationCount) {
157+
$invocationCount++;
158+
switch ($invocationCount) {
157159
case 1:
158160
$this->assertEquals(IndicesConfigurator::class, $className);
159161
$this->assertEquals('saveConfigurationToAlgolia', $method);
@@ -202,8 +204,8 @@ public function testProcessBatchHandlesFullIndexingPaged()
202204
$this->productHelper->method('getProductCollectionQuery')->willReturn($this->getMockCollection());
203205
$this->queueHelper->method('useTmpIndex')->willReturn(false);
204206

205-
$invocations = $this->exactly(6);
206-
$this->queue->expects($invocations)
207+
$invocationCount = 0;
208+
$this->queue->expects($this->exactly(6))
207209
->method('addToQueue')
208210
->willReturnCallback(
209211
function(
@@ -212,9 +214,9 @@ function(
212214
array $data,
213215
int $dataSize,
214216
bool $isFullReindex)
215-
use ($invocations, $pageSize) {
216-
$invocation = $invocations->getInvocationCount();
217-
switch ($invocation) {
217+
use (&$invocationCount, $pageSize) {
218+
$invocationCount++;
219+
switch ($invocationCount) {
218220
case 1:
219221
$this->assertEquals(IndicesConfigurator::class, $className);
220222
$this->assertEquals('saveConfigurationToAlgolia', $method);
@@ -224,7 +226,7 @@ function(
224226
$this->assertEquals('buildIndexFull', $method);
225227
$this->assertArrayHasKey('options', $data);
226228
$this->assertEquals($pageSize, $data['options']['pageSize']);
227-
$this->assertEquals($invocation - 1, $data['options']['page']);
229+
$this->assertEquals($invocationCount - 1, $data['options']['page']);
228230
break;
229231
}
230232
}
@@ -249,8 +251,8 @@ public function testProcessBatchMovesTempIndexIfQueueActive()
249251

250252
$this->queueHelper->method('useTmpIndex')->willReturn(true);
251253

252-
$invocations = $this->exactly(3);
253-
$this->queue->expects($invocations)
254+
$invocationCount = 0;
255+
$this->queue->expects($this->exactly(3))
254256
->method('addToQueue')
255257
->willReturnCallback(
256258
function(
@@ -259,8 +261,9 @@ function(
259261
array $data,
260262
int $dataSize,
261263
bool $isFullReindex)
262-
use ($invocations) {
263-
if ($invocations->getInvocationCount() === 3) {
264+
use (&$invocationCount) {
265+
$invocationCount++;
266+
if ($invocationCount === 3) {
264267
$this->assertEquals(IndexMover::class, $className);
265268
$this->assertEquals('moveIndexWithSetSettings', $method);
266269
$this->assertArrayHasKey('tmpIndexName', $data);

0 commit comments

Comments
 (0)