public function testRevertAfterPatch() { file_put_contents($this->file, 'ORIGINAL CONTENT'); $fileName = $this->file; $exercise = $this->getMock(ExerciseInterface::class); $this->codePatcher->expects($this->once())->method('patch')->with($exercise, 'ORIGINAL CONTENT')->will($this->returnValue('MODIFIED CONTENT')); $listener = new CodePatchListener($this->codePatcher); $event = new Event('event', compact('exercise', 'fileName')); $listener->patch($event); $listener->revert($event); $this->assertStringEqualsFile($this->file, 'ORIGINAL CONTENT'); }
public function testRevertAfterPatch() { file_put_contents($this->file, 'ORIGINAL CONTENT'); $input = new Input('app', ['program' => $this->file]); $exercise = $this->createMock(ExerciseInterface::class); $this->codePatcher->expects($this->once())->method('patch')->with($exercise, 'ORIGINAL CONTENT')->will($this->returnValue('MODIFIED CONTENT')); $listener = new CodePatchListener($this->codePatcher); $event = new ExerciseRunnerEvent('event', $exercise, $input); $listener->patch($event); $listener->revert($event); $this->assertStringEqualsFile($this->file, 'ORIGINAL CONTENT'); }