Skip to content

Commit f0e46f4

Browse files
committed
Add support of php 8.4 to cloud-patches
1 parent decb1fb commit f0e46f4

14 files changed

+166
-545
lines changed

src/Test/Unit/Command/Process/Action/ApplyOptionalActionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testExecuteSuccessful()
124124
]);
125125
$this->renderer->expects($this->exactly(3))
126126
->method('printPatchInfo')
127-
->willReturnCallback(function() use ($patch1, $patch2, $patch3) {
127+
->willReturnCallback(function($patch, $message) use ($patch1, $patch2, $patch3) {
128128
static $callCount = 0;
129129
$expectedPatches = [$patch1, $patch2, $patch3];
130130
$expectedMessages = [
@@ -261,7 +261,7 @@ public function testApplyWithException()
261261
});
262262
$this->conflictProcessor->expects($this->once())
263263
->method('process')
264-
->willReturnCallback(function() use ($patch1, $patch2, $patch3) {
264+
->willReturnCallback(function($patch, $message) use ($patch1, $patch2, $patch3) {
265265
static $callCount = 0;
266266
$expectedPatches = [$patch1, $patch2, $patch3];
267267
$expectedMessages = [

src/Test/Unit/Command/Process/Action/ConfirmRequiredActionTest.php

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public function testAskConfirmationForNotAppliedPatches()
8686
]);
8787

8888
/** @var InputInterface|MockObject $inputMock */
89-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
89+
$inputMock = $this->createMock(InputInterface::class);
9090
/** @var OutputInterface|MockObject $outputMock */
91-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
91+
$outputMock = $this->createMock(OutputInterface::class);
9292
$this->optionalPool->expects($this->once())
9393
->method('getAdditionalRequiredPatches')
9494
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
@@ -99,7 +99,7 @@ public function testAskConfirmationForNotAppliedPatches()
9999
})
100100
->willReturn([$patch1, $patch2, $patch3]);
101101

102-
$aggregatedPatch = $this->getMockForAbstractClass(AggregatedPatchInterface::class);
102+
$aggregatedPatch = $this->createMock(AggregatedPatchInterface::class);
103103
$this->aggregator->expects($this->once())
104104
->method('aggregate')
105105
->with([$patch1, $patch2])
@@ -108,7 +108,7 @@ public function testAskConfirmationForNotAppliedPatches()
108108
$this->renderer->expects($this->once())
109109
->method('printTable')
110110
->with($outputMock, [$aggregatedPatch])
111-
->willReturnCallback(function($output,$patches ) use ($outputMock, $aggregatedPatch) {
111+
->willReturnCallback(function($output) use ($outputMock, $aggregatedPatch) {
112112
if ($output === $outputMock && $aggregatedPatch === [$aggregatedPatch] ) {
113113
throw new RuntimeException('Error message');
114114
}
@@ -129,17 +129,12 @@ public function testPatchNotFoundException()
129129
$patchFilter = ['unknown id'];
130130

131131
/** @var InputInterface|MockObject $inputMock */
132-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
132+
$inputMock = $this->createMock(InputInterface::class);
133133
/** @var OutputInterface|MockObject $outputMock */
134-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
135-
$this->optionalPool->expects($this->once())
134+
$outputMock = $this->createMock(OutputInterface::class);
135+
$this->optionalPool->expects($this->once())
136136
->method('getAdditionalRequiredPatches')
137-
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
138-
if ($filter === $patchFilter) {
139-
return [$patch1];
140-
}
141-
return [];
142-
})
137+
->with($patchFilter)
143138
->willThrowException(new PatchNotFoundException(''));
144139

145140
$this->expectException(RuntimeException::class);
@@ -159,9 +154,9 @@ public function testConfirmationRejected()
159154
]);
160155

161156
/** @var InputInterface|MockObject $inputMock */
162-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
157+
$inputMock = $this->createMock(InputInterface::class);
163158
/** @var OutputInterface|MockObject $outputMock */
164-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
159+
$outputMock = $this->createMock(OutputInterface::class);
165160
$this->optionalPool->expects($this->once())
166161
->method('getAdditionalRequiredPatches')
167162
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
@@ -172,21 +167,16 @@ public function testConfirmationRejected()
172167
})
173168
->willReturn([$patch1]);
174169

175-
$aggregatedPatch = $this->getMockForAbstractClass(AggregatedPatchInterface::class);
170+
$aggregatedPatch = $this->createMock(AggregatedPatchInterface::class);
176171
$this->aggregator->expects($this->once())
177172
->method('aggregate')
178173
->with([$patch1])
179174
->willReturn([$aggregatedPatch]);
180175

181-
$this->renderer->expects($this->once())
182-
->method('printTable')
183-
->with($outputMock, [$aggregatedPatch])
184-
->willReturnCallback(function($output,$patches ) use ($outputMock, $aggregatedPatch) {
185-
if ($output === $outputMock && $aggregatedPatch === [$aggregatedPatch] ) {
186-
throw new RuntimeException('Error message');
187-
}
188-
return null;
189-
});
176+
$this->optionalPool->expects($this->once())
177+
->method('getAdditionalRequiredPatches')
178+
->with($patchFilter)
179+
->willReturn([$patch1]);
190180

191181
$this->renderer->expects($this->once())
192182
->method('printQuestion')
@@ -207,7 +197,7 @@ public function testConfirmationRejected()
207197
*/
208198
private function createPatch(string $path, string $id, bool $isDeprecated = false)
209199
{
210-
$patch = $this->getMockForAbstractClass(PatchInterface::class);
200+
$patch = $this->createMock(PatchInterface::class);
211201
$patch->method('getPath')->willReturn($path);
212202
$patch->method('getFilename')->willReturn('filename.patch');
213203
$patch->method('getId')->willReturn($id);

src/Test/Unit/Command/Process/Action/RevertActionTest.php

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ public function testExecuteSuccessful()
105105
]);
106106

107107
/** @var InputInterface|MockObject $inputMock */
108-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
108+
$inputMock = $this->createMock(InputInterface::class);
109109
/** @var OutputInterface|MockObject $outputMock */
110-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
110+
$outputMock = $this->createMock(OutputInterface::class);
111111
$this->optionalPool->expects($this->once())
112112
->method('getList')
113113
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
@@ -126,7 +126,7 @@ public function testExecuteSuccessful()
126126

127127
$this->renderer->expects($this->exactly(2))
128128
->method('printPatchInfo')
129-
->willReturnCallback(function() use ($patch1, $patch2) {
129+
->willReturnCallback(function($patch, $message) use ($patch1, $patch2) {
130130
static $callCount = 0;
131131
$expectedPatches = [$patch1, $patch2];
132132
$expectedMessages = [
@@ -160,9 +160,9 @@ public function testRevertNotAppliedPatch()
160160
]);
161161

162162
/** @var InputInterface|MockObject $inputMock */
163-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
163+
$inputMock = $this->createMock(InputInterface::class);
164164
/** @var OutputInterface|MockObject $outputMock */
165-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
165+
$outputMock = $this->createMock(OutputInterface::class);
166166
$this->optionalPool->expects($this->once())
167167
->method('getList')
168168
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
@@ -181,7 +181,7 @@ public function testRevertNotAppliedPatch()
181181
$outputMock->expects($this->once())
182182
->method('writeln')
183183
->willReturnCallback(function($patchId) use ($patchFilter,$patch1) {
184-
if ($patchId === $expectedMessage && $$patch1 === $patch1->getId()) {
184+
if ($patchId === $patch1->getId()) {
185185
$this->stringContains(
186186
'Patch ' . $patch1->getId() . ' (' . $patch1->getFilename() . ') is not applied'
187187
);
@@ -203,9 +203,9 @@ public function testRevertWithException()
203203
$errorMessage = sprintf('Reverting patch %s (%s) failed.', $patch1->getId(), $patch1->getPath());
204204

205205
/** @var InputInterface|MockObject $inputMock */
206-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
206+
$inputMock = $this->createMock(InputInterface::class);
207207
/** @var OutputInterface|MockObject $outputMock */
208-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
208+
$outputMock = $this->createMock(OutputInterface::class);
209209
$this->optionalPool->method('getList')
210210
->willReturn([$patch1]);
211211

@@ -232,17 +232,12 @@ public function testPatchNotFoundException()
232232
$patchFilter = ['unknown id'];
233233

234234
/** @var InputInterface|MockObject $inputMock */
235-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
235+
$inputMock = $this->createMock(InputInterface::class);
236236
/** @var OutputInterface|MockObject $outputMock */
237-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
238-
$this->optionalPool->expects($this->once())
237+
$outputMock = $this->createMock(OutputInterface::class);
238+
$this->optionalPool->expects($this->once())
239239
->method('getList')
240-
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
241-
if ($filter === $patchFilter) {
242-
return [$patch1];
243-
}
244-
return [];
245-
})
240+
->with($patchFilter)
246241
->willThrowException(new PatchNotFoundException(''));
247242

248243
$this->expectException(RuntimeException::class);
@@ -257,19 +252,15 @@ public function testValidationFailedException()
257252
$patchFilter = ['MC-11111'];
258253

259254
/** @var InputInterface|MockObject $inputMock */
260-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
255+
$inputMock = $this->createMock(InputInterface::class);
261256
/** @var OutputInterface|MockObject $outputMock */
262-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
257+
$outputMock = $this->createMock(OutputInterface::class);
263258

264-
$this->revertValidator->expects($this->once())
259+
$this->revertValidator->expects($this->once())
265260
->method('validate')
266-
->willReturnCallback(function($filter) use ($patchFilter, $patch1) {
267-
if ($filter === $patchFilter) {
268-
return [$patch1];
269-
}
270-
return [];
271-
})
261+
->with($patchFilter)
272262
->willThrowException(new RuntimeException('Error'));
263+
273264
$this->optionalPool->expects($this->never())
274265
->method('getList');
275266

@@ -287,7 +278,7 @@ public function testValidationFailedException()
287278
*/
288279
private function createPatch(string $path, string $id)
289280
{
290-
$patch = $this->getMockForAbstractClass(PatchInterface::class);
281+
$patch = $this->createMock(PatchInterface::class);
291282
$patch->method('getPath')->willReturn($path);
292283
$patch->method('getId')->willReturn($id);
293284

src/Test/Unit/Command/Process/Action/ReviewAppliedActionTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ReviewAppliedActionTest extends TestCase
5454
*/
5555
protected function setUp(): void
5656
{
57-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
57+
$this->logger = $this->createMock(LoggerInterface::class);
5858
$this->statusPool = $this->createMock(StatusPool::class);
5959
$this->optionalPool = $this->createMock(OptionalPool::class);
6060

@@ -82,9 +82,9 @@ public function testAppliedPatchesExceedsLimit()
8282
}
8383

8484
/** @var InputInterface|MockObject $inputMock */
85-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
85+
$inputMock = $this->createMock(InputInterface::class);
8686
/** @var OutputInterface|MockObject $outputMock */
87-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
87+
$outputMock = $this->createMock(OutputInterface::class);
8888

8989
$this->statusPool->method('isApplied')
9090
->willReturn(true);
@@ -95,12 +95,7 @@ public function testAppliedPatchesExceedsLimit()
9595

9696
$outputMock->expects($this->once())
9797
->method('writeln')
98-
->willReturnCallback(function($filter) use ($patch1) {
99-
if ($filter === $patch1) {
100-
$this->stringContains('error');
101-
}
102-
return false;
103-
});
98+
->with($this->stringContains('error'));
10499

105100
$this->action->execute($inputMock, $outputMock, $patchFilter);
106101
}
@@ -116,9 +111,9 @@ public function testAppliedPatchesNotExceedLimit()
116111
}
117112

118113
/** @var InputInterface|MockObject $inputMock */
119-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
114+
$inputMock = $this->createMock(InputInterface::class);
120115
/** @var OutputInterface|MockObject $outputMock */
121-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
116+
$outputMock = $this->createMock(OutputInterface::class);
122117

123118
$this->statusPool->method('isApplied')
124119
->willReturn(true);
@@ -142,7 +137,7 @@ public function testAppliedPatchesNotExceedLimit()
142137
*/
143138
private function createPatch(string $id)
144139
{
145-
$patch = $this->getMockForAbstractClass(PatchInterface::class);
140+
$patch = $this->createMock(PatchInterface::class);
146141
$patch->method('getId')->willReturn($id);
147142

148143
return $patch;

src/Test/Unit/Command/Process/ApplyLocalTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ApplyLocalTest extends TestCase
6262
protected function setUp(): void
6363
{
6464
$this->applier = $this->createMock(Applier::class);
65-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
65+
$this->logger = $this->createMock(LoggerInterface::class);
6666
$this->localPool = $this->createMock(LocalPool::class);
6767
$this->renderer = $this->createMock(Renderer::class);
6868
$this->rollbackProcessor = $this->createMock(RollbackProcessor::class);
@@ -86,9 +86,9 @@ public function testExecuteLocalPatchesNotFound()
8686
$expectedMessage = '<info>Hot-fixes were not found. Skipping</info>';
8787

8888
/** @var InputInterface|MockObject $inputMock */
89-
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
89+
$inputMock = $this->createMock(InputInterface::class);
9090
/** @var OutputInterface|MockObject $outputMock */
91-
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
91+
$outputMock = $this->createMock(OutputInterface::class);
9292
$this->localPool->method('getList')
9393
->willReturn([]);
9494
$outputMock->expects($this->once())
@@ -125,7 +125,7 @@ public function testApplySuccessful()
125125

126126
$outputMock->expects($this->exactly(4))
127127
->method('writeln')
128-
->willReturnCallback(function() use ($patch1, $patch2, $patch3) {
128+
->willReturnCallback(function($patch, $message) use ($patch1, $patch2, $patch3) {
129129
static $callCount = 0;
130130
$expectedPatches = [$patch1, $patch2, $patch3];
131131
$expectedMessages = [

src/Test/Unit/Command/Process/ApplyOptionalTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,9 @@ public function testApplyWithPatchArgumentProvided()
8080
->with($cliPatchArgument)
8181
->willReturn($cliPatchArgument);
8282

83-
$this->actionPool->expects($this->once())
83+
$this->actionPool->expects($this->once())
8484
->method('execute')
85-
->willReturnCallback(function($input, $output, $cliPatch) use ($inputputMock, $outputMock, $patch) {
86-
if ($input === $inputputMock && $output === $outputMock && $patches === $cliPatch) {
87-
return true;
88-
}
89-
return false;
90-
});
85+
->with($inputMock, $outputMock, $cliPatchArgument);
9186
$this->applyOptional->run($inputMock, $outputMock);
9287
}
9388

0 commit comments

Comments
 (0)