From ffa8276f79af4b2d6e4f8429611b213db0f0e68f Mon Sep 17 00:00:00 2001 From: Janosch Woschitz Date: Mon, 28 Apr 2014 19:22:13 +0200 Subject: [PATCH 1/2] load configuration even if libxml entity loader is disabled --- src/ParaTest/Runners/PHPUnit/Configuration.php | 9 ++++++--- test/ParaTest/Runners/PHPUnit/ConfigurationTest.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ParaTest/Runners/PHPUnit/Configuration.php b/src/ParaTest/Runners/PHPUnit/Configuration.php index f4650a4f..21508aed 100644 --- a/src/ParaTest/Runners/PHPUnit/Configuration.php +++ b/src/ParaTest/Runners/PHPUnit/Configuration.php @@ -34,13 +34,16 @@ class Configuration public function __construct($path) { $this->path = $path; - if(file_exists($path)) + if(file_exists($path)) { + $before = libxml_disable_entity_loader(false); $this->xml = simplexml_load_file($path); + libxml_disable_entity_loader($before); + } } - + /** * Get the bootstrap PHPUnit configuration attribute - * + * * @return string The bootstrap attribute or empty string if not set */ public function getBootstrap() diff --git a/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php b/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php index 1d442bd3..11c8c2e6 100644 --- a/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php +++ b/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php @@ -44,4 +44,15 @@ public function testSuitesContainPathAsValue($suites) $this->assertEquals(array($basePath . 'it' . DS . 'ParaTest'), $suites["ParaTest Integration Tests"]); $this->assertEquals(array($basePath . 'functional'), $suites["ParaTest Functional Tests"]); } + + public function testLoadConfigEvenIfLibXmlEntityLoaderIsDisabled() + { + $before = libxml_disable_entity_loader(); + try { + $this->config = new Configuration($this->path); + } catch (\Exception $e) { + libxml_disable_entity_loader($before); + throw $e; + } + } } From 9dba8d47ad1f74c73010e078fa667e3619b64476 Mon Sep 17 00:00:00 2001 From: Janosch Woschitz Date: Tue, 29 Apr 2014 11:18:30 +0200 Subject: [PATCH 2/2] fixed test, libxml_disable_entity_loader will be always restored now --- test/ParaTest/Runners/PHPUnit/ConfigurationTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php b/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php index 11c8c2e6..fe615fe9 100644 --- a/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php +++ b/test/ParaTest/Runners/PHPUnit/ConfigurationTest.php @@ -48,11 +48,16 @@ public function testSuitesContainPathAsValue($suites) public function testLoadConfigEvenIfLibXmlEntityLoaderIsDisabled() { $before = libxml_disable_entity_loader(); + $e = null; + try { $this->config = new Configuration($this->path); - } catch (\Exception $e) { - libxml_disable_entity_loader($before); - throw $e; + } catch (\Exception $exc) { + $e = $exc; } + + libxml_disable_entity_loader($before); + + $this->assertNull($e, 'Could not instantiate Configuration: ' . ($e instanceof \Exception ? $e->getMessage() : 'no error given')); } }