Beispiel #1
0
 /**
  * Tests method without exceptions.
  *
  * @covers ::resolveSchemaUri
  *
  * @return void
  */
 public function testResolveSchemaUri()
 {
     $definition = new InputDefinition([new InputArgument('file', InputArgument::REQUIRED), new InputArgument('schema', InputArgument::REQUIRED)]);
     $arguments = ['file' => __FILE__, 'schema' => 'http://httpbin.org/status/200'];
     $input = new ArrayInput($arguments, $definition);
     Utils::resolveSchemaUri($input);
     $this->assertStringEndsWith('/tmp.json', $input->getArgument('schema'));
 }
 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance.
  * @param OutputInterface $output An OutputInterface instance.
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Utils::resolveSchemaUri($input);
     $schema = $input->getArgument('schema');
     $schema = (new UriRetriever())->retrieve('file://' . realpath($schema));
     $data = json_decode(file_get_contents($input->getArgument('file')));
     $validator = new Validator();
     $validator->check($data, $schema);
     if ($validator->isValid()) {
         $output->writeln('<info>The supplied JSON validates against the schema.</info>');
         return 0;
     }
     Utils::displayErrors($validator, $output);
     return 1;
 }