示例#1
0
 public function testReportProblemCreatesValidationProblem()
 {
     $report = FileReport::create('test_file.xml');
     $report->reportProblem('my_message');
     $result = $report->getProblems();
     $problem = reset($result);
     $this->assertInstanceOf(ValidationProblem::class, $problem);
     $this->assertEquals('my_message', $problem->getMessage());
 }
 /**
  * @dataProvider getMockReturnValues
  * @param bool $return1
  * @param bool $return2
  * @param bool $expected
  */
 public function testCollectionCorrectReturnValue($return1, $return2, $expected)
 {
     $mock1 = $this->getMockBuilder(ValidationInterface::class)->getMock();
     $mock2 = $this->getMockBuilder(ValidationInterface::class)->getMock();
     $mock1->method('validateFile')->willReturn($return1);
     $mock2->method('validateFile')->willReturn($return2);
     $collection = new ValidationCollection();
     /** @var ValidationInterface $mock1 */
     /** @var ValidationInterface $mock2 */
     $collection->addValidation($mock1)->addValidation($mock2);
     $this->assertEquals($expected, $collection->validateFile(FileReport::create('some_file.xml')));
 }
示例#3
0
 /**
  * lint a file, pass errors to the queue
  * @param \SplFileInfo $file
  * @return bool
  */
 private function lintFile(\SplFileInfo $file)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->write('lint file ' . $file . ' ... ');
     }
     $report = FileReport::create($file);
     $this->reports[] = $report;
     $status = $this->validator->validateFile($report);
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         if ($status === false) {
             $this->output->writeln('<error>errors</error>');
         } else {
             $this->output->writeln('<info>passed.</info>');
         }
     } else {
         if ($status === false) {
             $this->output->write('<error>F</error>');
         } else {
             $this->output->write('.');
         }
     }
     return $status;
 }