setXInclude() public method

public setXInclude ( boolean $xInclude )
$xInclude boolean
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $files = $context->getFiles()->name('*.xml');
     if (0 === count($files)) {
         return;
     }
     $config = $this->getConfiguration();
     $this->linter->setLoadFromNet($config['load_from_net']);
     $this->linter->setXInclude($config['x_include']);
     $this->linter->setDtdValidation($config['dtd_validation']);
     $this->linter->setSchemeValidation($config['scheme_validation']);
     $lintErrors = $this->lint($files);
     if ($lintErrors->count()) {
         throw new RuntimeException($lintErrors->__toString());
     }
 }
Ejemplo n.º 2
0
 function it_throws_exception_if_the_process_fails(XmlLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setLoadFromNet(false)->shouldBeCalled();
     $linter->setXInclude(false)->shouldBeCalled();
     $linter->setDtdValidation(false)->shouldBeCalled();
     $linter->setSchemeValidation(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection(array(new XmlLintError(LintError::TYPE_ERROR, 0, 'error', 'file.xml', 1, 1))));
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file.xml', '.', 'file.xml'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $config = $this->getConfiguration();
     $files = $context->getFiles()->extensions($config['triggered_by']);
     if (0 === count($files)) {
         return TaskResult::createSkipped($this, $context);
     }
     $this->linter->setLoadFromNet($config['load_from_net']);
     $this->linter->setXInclude($config['x_include']);
     $this->linter->setDtdValidation($config['dtd_validation']);
     $this->linter->setSchemeValidation($config['scheme_validation']);
     try {
         $lintErrors = $this->lint($files);
     } catch (RuntimeException $e) {
         return TaskResult::createFailed($this, $context, $e->getMessage());
     }
     if ($lintErrors->count()) {
         return TaskResult::createFailed($this, $context, (string) $lintErrors);
     }
     return TaskResult::createPassed($this, $context);
 }
Ejemplo n.º 4
0
 function it_throws_exception_if_the_process_fails(XmlLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setLoadFromNet(false)->shouldBeCalled();
     $linter->setXInclude(false)->shouldBeCalled();
     $linter->setDtdValidation(false)->shouldBeCalled();
     $linter->setSchemeValidation(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection([new XmlLintError(LintError::TYPE_ERROR, 0, 'error', 'file.xml', 1, 1)]));
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file.xml', '.', 'file.xml')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
Ejemplo n.º 5
0
 /**
  * @test
  * @dataProvider provideXincludeValidation
  */
 function it_can_handle_xincludes($fixture, $errors)
 {
     $this->linter->setXInclude(true);
     $this->validateFixture($fixture, $errors);
 }