public function testFromCheckAndExerciseConstructor() { $exercise = $this->createMock(ExerciseInterface::class); $exercise->expects($this->once())->method('getName')->will($this->returnValue('Some Exercise')); $exercise->expects($this->once())->method('getType')->will($this->returnValue(ExerciseType::CLI())); $check = $this->createMock(CheckInterface::class); $check->expects($this->once())->method('getName')->will($this->returnValue('Some Check')); $e = CheckNotApplicableException::fromCheckAndExercise($check, $exercise); $msg = 'Check: "Some Check" cannot process exercise: "Some Exercise" with type: "CLI"'; $this->assertSame($msg, $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); } } }