minor #16380 Set back libxml settings after testings. (SpacePossum)

This PR was merged into the 2.3 branch.

Discussion
----------

Set back libxml settings after testings.

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | none
| License       | MIT
| Doc PR        | none

Tests that change the `libxml_use_internal_errors` should set back the flag to the previous setting when done testing.

Commits
-------

29d6969 Set back libxml settings after testings.
This commit is contained in:
Fabien Potencier 2015-10-29 11:36:05 -07:00
commit eed6a68f91
2 changed files with 9 additions and 3 deletions

View File

@ -63,11 +63,14 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
public function testLoadFileWithInternalErrorsEnabled()
{
libxml_use_internal_errors(true);
$internalErrors = libxml_use_internal_errors(true);
$this->assertSame(array(), libxml_get_errors());
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml'));
$this->assertSame(array(), libxml_get_errors());
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
}
/**
@ -144,7 +147,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
public function testLoadEmptyXmlFile()
{
$file = __DIR__.'/../Fixtures/foo.xml';
$this->setExpectedException('InvalidArgumentException', 'File '.$file.' does not contain valid XML, it is empty.');
$this->setExpectedException('InvalidArgumentException', sprintf('File %s does not contain valid XML, it is empty.', $file));
XmlUtils::loadFile($file);
}

View File

@ -30,7 +30,7 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase
public function testLoadWithInternalErrorsEnabled()
{
libxml_use_internal_errors(true);
$internalErrors = libxml_use_internal_errors(true);
$this->assertSame(array(), libxml_get_errors());
@ -41,6 +41,9 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
$this->assertSame(array(), libxml_get_errors());
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
}
public function testLoadWithResname()