Skip to content

Commit 3342864

Browse files
committed
Make patch revert silent when no reverts possible
1 parent abb89cd commit 3342864

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

src/Listener/CodePatchListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function patch(ExerciseRunnerEvent $event): void
6363
public function revert(\PhpSchool\PhpWorkshop\Event\EventInterface $event): void
6464
{
6565
if (null === $this->originalCode || empty($this->originalCode)) {
66-
throw new RuntimeException('Can only revert previously patched code');
66+
return;
6767
}
6868

6969
foreach ($this->originalCode as $fileName => $contents) {

test/Listener/CodePatchListenerTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@ public function setUp(): void
3838
touch($this->file);
3939
}
4040

41-
public function testRevertThrowsExceptionIfPatchNotPreviouslyCalled(): void
42-
{
43-
$input = new Input('app', ['program' => $this->file]);
44-
$exercise = $this->createMock(ExerciseInterface::class);
45-
46-
$listener = new CodePatchListener($this->codePatcher);
47-
$event = new ExerciseRunnerEvent('event', $exercise, $input);
48-
49-
$this->expectException(RuntimeException::class);
50-
$this->expectExceptionMessage('Can only revert previously patched code');
51-
$listener->revert($event);
52-
}
53-
5441
public function testPatchUpdatesCode(): void
5542
{
5643
file_put_contents($this->file, 'ORIGINAL CONTENT');

0 commit comments

Comments
 (0)