Skip to content

Commit 41655fa

Browse files
committed
Migrate some tests from prophecy
1 parent e4dcebd commit 41655fa

File tree

3 files changed

+162
-162
lines changed

3 files changed

+162
-162
lines changed

test/Command/PrintCommandTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ public function testExerciseIsPrintedIfAssigned(): void
1818
$file = tempnam(sys_get_temp_dir(), 'pws');
1919
file_put_contents($file, '### Exercise 1');
2020

21-
$exercise = $this->prophesize(CliExerciseInterface::class);
22-
$exercise->getProblem()->willReturn($file);
23-
$exercise->getType()->willReturn(ExerciseType::CLI());
24-
$exercise->getName()->willReturn('some-exercise');
21+
$exercise = $this->createMock(CliExerciseInterface::class);
22+
$exercise
23+
->method('getProblem')
24+
->willReturn($file);
2525

26-
$repo = new ExerciseRepository([$exercise->reveal()]);
26+
$exercise
27+
->method('getType')
28+
->willReturn(ExerciseType::CLI());
29+
30+
$exercise
31+
->method('getName')
32+
->willReturn('some-exercise');
33+
34+
$repo = new ExerciseRepository([$exercise]);
2735

2836
$state = new UserState();
2937
$state->setCurrentExercise('some-exercise');

test/Command/RunCommandTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ public function test(): void
2828
$color->setForceStyle(true);
2929
$output = new StdOutput($color, $this->createMock(Terminal::class));
3030

31-
$dispatcher = $this->prophesize(ExerciseDispatcher::class);
32-
$dispatcher->run($exercise, $input, $output)->shouldBeCalled();
31+
$dispatcher = $this->createMock(ExerciseDispatcher::class);
32+
$dispatcher
33+
->expects($this->once())
34+
->method('run')
35+
->with($exercise, $input, $output);
3336

34-
$command = new RunCommand($repo, $dispatcher->reveal(), $state, $output);
37+
$command = new RunCommand($repo, $dispatcher, $state, $output);
3538
$command->__invoke($input);
3639
}
3740
}

0 commit comments

Comments
 (0)