Exemple #1
0
 public function testFailure()
 {
     $failure = new Failure($this->check->getName(), 'Something went wrong yo');
     $this->assertInstanceOf(ResultInterface::class, $failure);
     $this->assertEquals('Something went wrong yo', $failure->getReason());
     $this->assertEquals('Some Check', $failure->getCheckName());
 }
 public function setUp()
 {
     $this->check = new CodeParseCheck((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
     $this->assertEquals('Code Parse Check', $this->check->getName());
     $this->assertEquals(ExerciseInterface::class, $this->check->getExerciseInterface());
     $this->assertTrue($this->check->canRun(ExerciseType::CGI()));
     $this->assertTrue($this->check->canRun(ExerciseType::CLI()));
     $this->file = sprintf('%s/%s/submission.php', str_replace('\\', '/', sys_get_temp_dir()), $this->getName());
     mkdir(dirname($this->file), 0775, true);
     touch($this->file);
 }
 /**
  * Get the check name from the underlying check. Assumes that the `check` property has been
  * assigned an instance of `PhpSchool\PhpWorkshop\Check\CheckInterface`.
  *
  * @return string
  */
 public function getCheckName()
 {
     return $this->check->getName();
 }
 /**
  * @param CheckInterface $check
  * @return static
  */
 public static function fromCheck(CheckInterface $check)
 {
     return new static($check->getName());
 }
Exemple #5
0
 /**
  * @param CheckInterface $check
  * @param ParseErrorException $e
  * @param string $file
  * @return static
  */
 public static function fromCheckAndCodeParseFailure(CheckInterface $check, ParseErrorException $e, $file)
 {
     return new static($check->getName(), sprintf('File: "%s" could not be parsed. Error: "%s"', $file, $e->getMessage()));
 }
 /**
  * @param CheckInterface $check
  * @param $expectedOutput
  * @param $actualOutput
  * @return static
  */
 public static function fromCheckAndOutput(CheckInterface $check, $expectedOutput, $actualOutput)
 {
     return new static($check->getName(), $expectedOutput, $actualOutput);
 }
 /**
  * Static constructor to create an instance from the check & exercise.
  *
  * @param CheckInterface $check The check Instance.
  * @param ExerciseInterface $exercise The exercise Instance.
  * @return static
  */
 public static function fromCheckAndExercise(CheckInterface $check, ExerciseInterface $exercise)
 {
     return new static(sprintf('Check: "%s" cannot process exercise: "%s" with type: "%s"', $check->getName(), $exercise->getName(), $exercise->getType()));
 }