Skip to content

Commit

Permalink
Validando pattern de TiposBasicos
Browse files Browse the repository at this point in the history
  • Loading branch information
gersonfs committed Jun 7, 2024
1 parent d72ff77 commit c36bd87
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/TiposBasicosTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace NFePHP\NFe\Tests;

use PHPUnit\Framework\TestCase;

class TiposBasicosTest extends TestCase
{
public function test_TString(): void
{
if (PHP_VERSION_ID < 80100) {
$this->markTestSkipped('Versão muito baixa do PHP para o teste');
}

$doc = new \DOMDocument();
$xsdstring = file_get_contents(dirname(__DIR__) . '/schemes/PL_009_V4/tiposBasico_v4.00.xsd');
$doc->loadXML(mb_convert_encoding($xsdstring, 'utf-8', mb_detect_encoding($xsdstring)));
$xpath = new \DOMXPath($doc);
$xpath->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema');

$item = $xpath->query('xs:simpleType[@name="TString"]/xs:restriction/xs:pattern')->item(0);
$this->assertNotNull($item, 'Não foi encontrado o simpleType TString');
/** @var \DOMNamedNodeMap $atributos */
$atributos = $item->attributes;

/** @var \DOMAttr $node */
$node = $atributos->getNamedItem('value');

$this->assertEquals(
'[!-ÿ]{1}[ -ÿ]*[!-ÿ]{1}|[!-ÿ]{1}',
$node->value,
'Por favor, corrija o pattern no arquivo tiposBasico_v4.00.xsd. Issue #940'
);
}
}

0 comments on commit c36bd87

Please sign in to comment.