Skip to content

Commit

Permalink
ubl version resolver - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Oct 23, 2018
1 parent 33b5bc4 commit 3ba15f0
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/Ubl/Resolver/UblVersionResolverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Created by PhpStorm.
* User: Soporte
* Date: 23/10/2018
* Time: 15:07
*/

namespace Tests\Greenter\Ubl\Resolver;


use Greenter\Ubl\Resolver\UblVersionResolver;

class UblVersionResolverTest extends \PHPUnit_Framework_TestCase
{
/**
* @var UblVersionResolver
*/
private $resolver;

protected function setUp()
{
$this->resolver = new UblVersionResolver();
}

public function testSuccessValidate()
{
$path = __DIR__.'/../../Resources/2.1/20100454523-07-FC01-211.xml';
$xml = file_get_contents($path);

$version = $this->resolver->getVersion($xml);

$this->assertEquals('2.1', $version);
}

public function testSuccessValidateFromDoc()
{
$path = __DIR__.'/../../Resources/2.1/20100454523-07-FC01-211.xml';
$doc = new \DOMDocument();
$doc->load($path);

$version = $this->resolver->getVersion($doc);

$this->assertEquals('2.1', $version);
}

public function testNotFoundVersion()
{
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<text>-</text>
</root>
XML;
$version = $this->resolver->getVersion($xml);

$this->assertEmpty($version);
}

public function testEmptyXML()
{
$xml = '';
$version = $this->resolver->getVersion($xml);

$this->assertEmpty($version);
}
}

0 comments on commit 3ba15f0

Please sign in to comment.