Skip to content

Commit

Permalink
Add basic unitTest for xml validation (OpenMage#2304)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyingmana authored and elidrissidev committed Jul 22, 2022
1 parent 1a21e8d commit 3a1deaf
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions dev/tests/unit/Base/XmlFileLoadingTest.php
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);

namespace OpenMage\Tests\Unit\Base;

use PHPUnit\Framework\TestCase;

class XmlFileLoadingTest extends TestCase
{

public function provideXmlFiles(): array
{
$root = realpath(__DIR__ . '/../../../../') . '/';

$result = [];
$result[] = [
$root . 'lib/Zend/Locale/Data/es_419.xml'
];

return $result;
}

/**
*
* @dataProvider provideXmlFiles
* @param $filepath
* @return void
*/
public function testFileLoading($filepath): void
{
//$simplexml = new \SimpleXMLElement(file_get_contents($filepath));
$simplexml = simplexml_load_file(
$filepath,
null,
LIBXML_PEDANTIC //not needed by OpenMage, but good to test more strictly
);
$this->assertNotEmpty($simplexml->asXML());
}

/**
*
* @dataProvider provideXmlFiles
* @param $filepath
* @return void
*/
public function testXmlReaderIsValid($filepath): void
{
$xml = \XMLReader::open($filepath);
$xml->setParserProperty(\XMLReader::VALIDATE, true);
$this->assertTrue($xml->isValid());
}
}

0 comments on commit 3a1deaf

Please sign in to comment.