public function testMissingImplementsConstructor() { $exercise = $this->getMock(ExerciseInterface::class); $exercise->expects($this->once())->method('getName')->will($this->returnValue('Some Exercise')); $e = ExerciseNotConfiguredException::missingImplements($exercise, 'SomeInterface'); $this->assertSame('Exercise: "Some Exercise" should implement interface: "SomeInterface"', $e->getMessage()); }
/** * @param CheckInterface[] $checks * @param ExerciseInterface $exercise * @throws CheckNotApplicableException * @throws ExerciseNotConfiguredException */ private function validateChecks(array $checks, ExerciseInterface $exercise) { foreach ($checks as $check) { if (!$check->canRun($exercise->getType())) { throw CheckNotApplicableException::fromCheckAndExercise($check, $exercise); } $checkInterface = $check->getExerciseInterface(); if (!$exercise instanceof $checkInterface) { throw ExerciseNotConfiguredException::missingImplements($exercise, $checkInterface); } } }