public function testFailureFromCodeExecutionException() { $args = new ArrayObject(); $e = new CodeExecutionException('Something went wrong yo'); $failure = GenericFailure::fromArgsAndCodeExecutionFailure($args, $e); $this->assertInstanceOf(GenericFailure::class, $failure); $this->assertEquals($args, $failure->getArgs()); $this->assertEquals('Something went wrong yo', $failure->getReason()); $this->assertEquals('CLI Program Runner', $failure->getCheckName()); }
/** * @param array $args * @param Input $input * @return ResultInterface */ private function doVerify(array $args, Input $input) { //arrays are not pass-by-ref $args = new ArrayObject($args); try { $event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.reference-execute.pre', $args)); $solutionOutput = $this->executePhpFile($this->exercise->getSolution()->getEntryPoint(), $event->getArgs(), 'reference'); } catch (CodeExecutionException $e) { $this->eventDispatcher->dispatch(new Event('cli.verify.reference-execute.fail', ['exception' => $e])); throw new SolutionExecutionException($e->getMessage()); } try { $event = $this->eventDispatcher->dispatch(new CliExecuteEvent('cli.verify.student-execute.pre', $args)); $userOutput = $this->executePhpFile($input->getArgument('program'), $event->getArgs(), 'student'); } catch (CodeExecutionException $e) { $this->eventDispatcher->dispatch(new Event('cli.verify.student-execute.fail', ['exception' => $e])); return GenericFailure::fromArgsAndCodeExecutionFailure($args, $e); } if ($solutionOutput === $userOutput) { return new Success($args); } return RequestFailure::fromArgsAndOutput($args, $solutionOutput, $userOutput); }