Fix SettingsTest

SettingsTest was changing the global LibXMLLoaderOptions without restoring the original. This caused problems for one of my new tests.
This commit is contained in:
Owen Leibman 2021-06-30 11:33:35 -07:00
parent 36b328a9fa
commit 3bb574c302
2 changed files with 2 additions and 12 deletions

View File

@ -41,6 +41,7 @@ class SettingsTest extends TestCase
public function testSetXMLSettings(): void public function testSetXMLSettings(): void
{ {
$original = Settings::getLibXmlLoaderOptions();
Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID);
$result = Settings::getLibXmlLoaderOptions(); $result = Settings::getLibXmlLoaderOptions();
self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result)); self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result));
@ -48,5 +49,6 @@ class SettingsTest extends TestCase
if (\PHP_VERSION_ID < 80000) { if (\PHP_VERSION_ID < 80000) {
self::assertFalse(libxml_disable_entity_loader()); self::assertFalse(libxml_disable_entity_loader());
} }
Settings::setLibXmlLoaderOptions($original);
} }
} }

View File

@ -9,18 +9,6 @@ use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
class PasswordReloadTest extends AbstractFunctional class PasswordReloadTest extends AbstractFunctional
{ {
/** /**
* I don't know why separate process is needed for this test.
* I get a weird error without it, and I would rather just scrap the test
* than spend any more time debugging it.
* The test works fine without separate process (on Windows) with:
* php vendor\phpunit\phpunit\phpunit tests\PhpSpreadsheetTests\Shared\
* But it fails with:
* php vendor\phpunit\phpunit\phpunit tests\PhpSpreadsheetTests\
* The error is a mysterious:
* simplexml_load_string(): validity error : Validation failed: no DTD found !
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider providerPasswords * @dataProvider providerPasswords
*/ */
public function testPasswordReload(string $format, string $algorithm, bool $supported = true): void public function testPasswordReload(string $format, string $algorithm, bool $supported = true): void