Ejemplo n.º 1
0
 public function testParseableCodeReturnsSuccess()
 {
     file_put_contents($this->file, '<?php $lol = "lol";');
     $result = $this->check->check($this->createMock(ExerciseInterface::class), $this->file);
     $this->assertInstanceOf(Success::class, $result);
     $this->assertEquals('Code Parse Check', $result->getCheckName());
 }
Ejemplo n.º 2
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());
 }
Ejemplo n.º 3
0
 /**
  * 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();
 }
Ejemplo n.º 4
0
 /**
  * @param CheckInterface $check
  * @return static
  */
 public static function fromCheck(CheckInterface $check)
 {
     return new static($check->getName());
 }
Ejemplo n.º 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()));
 }
Ejemplo n.º 6
0
 /**
  * @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()));
 }
Ejemplo n.º 8
0
 public function setUp()
 {
     $this->check = $this->getMock(CheckInterface::class);
     $this->check->expects($this->any())->method('getName')->will($this->returnValue('Some Check'));
 }