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()); }
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()); }
/** * 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()); }
/** * @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())); }
public function setUp() { $this->check = $this->getMock(CheckInterface::class); $this->check->expects($this->any())->method('getName')->will($this->returnValue('Some Check')); }