public function testFailureWithReason() { $failure = Failure::fromCheckAndReason($this->check, 'Something went wrong yo'); $this->assertInstanceOf(ResultInterface::class, $failure); $this->assertEquals('Something went wrong yo', $failure->getReason()); $this->assertEquals('Some Check', $failure->getCheckName()); }
/** * Simply check that the file exists. * * @param ExerciseInterface $exercise The exercise to check against. * @param Input $input The command line arguments passed to the command. * @return ResultInterface The result of the check. */ public function check(ExerciseInterface $exercise, Input $input) { if (file_exists($input->getArgument('program'))) { return Success::fromCheck($this); } return Failure::fromCheckAndReason($this, sprintf('File: "%s" does not exist', $input->getArgument('program'))); }
/** * Simply check that the file exists. * * @param ExerciseInterface $exercise The exercise to check against. * @param string $fileName The absolute path to the student's solution. * @return ResultInterface The result of the check. */ public function check(ExerciseInterface $exercise, $fileName) { if (file_exists($fileName)) { return Success::fromCheck($this); } return Failure::fromCheckAndReason($this, sprintf('File: "%s" does not exist', $fileName)); }
/** * @param ExerciseInterface $exercise * @param string $fileName * @return Failure|Success */ public function check(ExerciseInterface $exercise, $fileName) { $process = new Process(sprintf('%s -l %s', PHP_BINARY, $fileName)); $process->run(); if ($process->isSuccessful()) { return Success::fromCheck($this); } return Failure::fromCheckAndReason($this, $process->getErrorOutput()); }