Skip to content

Commit

Permalink
up coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Jan 26, 2018
1 parent 8a0e313 commit 6f9bc8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea/
/build/
/vendor/
/composer.lock
.DS_Store
Expand Down
33 changes: 15 additions & 18 deletions src/Ubl/SchemaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,30 @@ private function getErrors()

public function getError($error)
{
$msg = '';
switch ($error->level) {
case LIBXML_ERR_WARNING:
$msg .= 'Alerta';
break;
case LIBXML_ERR_ERROR:
$msg .= 'Error';
break;
case LIBXML_ERR_FATAL:
$msg .= 'Error Fatal';
break;
}
$msg .= ' '.$error->code.': '.trim($error->message).' en la linea '.$error->line;
$msg = $error->code.': '.trim($error->message).' en la linea '.$error->line;

return $msg;
}

private function getFilename($rootName)
{
if ($this->version == '2.0') {
$name = $rootName == 'DespatchAdvice' ? 'UBL-DespatchAdvice-2.0' : 'UBLPE-'.$rootName.'-1.0';
} else {
$name = 'UBL-'.$rootName.'-2.1';
}
$name = $this->getName($rootName);

$path = __DIR__.'/../xsd/'.$this->version.'/maindoc/'.$name.'.xsd';

return $path;
}

/**
* @param $rootName
* @return string
*/
private function getName($rootName)
{
if ($this->version == '2.0') {
return $rootName == 'DespatchAdvice' ? 'UBL-DespatchAdvice-2.0' : 'UBLPE-' . $rootName . '-1.0';
}

return 'UBL-' . $rootName . '-2.1';
}
}
5 changes: 3 additions & 2 deletions tests/Ubl/SchemaValidatorV20Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public function testNotFoundSchema()

public function testInvalidSchema()
{
$content = file_get_contents(__DIR__.'/../Resources/error.xml');
$result = $this->validator->validate($content);
$doc = new \DOMDocument();
$doc->load(__DIR__.'/../Resources/error.xml');
$result = $this->validator->validate($doc);

$this->assertFalse($result);
$this->assertNotEmpty($this->validator->getMessage());
Expand Down

0 comments on commit 6f9bc8a

Please sign in to comment.