diff --git a/library/Class/Notice/Xsl.php b/library/Class/Notice/Xsl.php index ef7c8871e708ae089605c7fb30af844187a0ca7c..a4a23b3ed197cac37c9a3565942990ff448d6088 100644 --- a/library/Class/Notice/Xsl.php +++ b/library/Class/Notice/Xsl.php @@ -25,7 +25,9 @@ class Class_Notice_Xsl { const KEY = 'xslt'; - protected static $_xslt_processor; + protected static + $_xslt_processor, + $_dom_document; protected $_record, @@ -35,6 +37,7 @@ class Class_Notice_Xsl { public static function reset() { static::$_xslt_processor = null; + static::$_dom_document = null; static::setPhpCommand(null); static::setYaz(null); } @@ -121,7 +124,7 @@ class Class_Notice_Xsl { public function importStylesheet($path) { - $xsl = new DOMDocument(); + $xsl = $this->getDomDocument(); $xsl->load($path); $xslt = $this->getXSLTProcessor(); @@ -132,7 +135,7 @@ class Class_Notice_Xsl { public function transformToXml($path) { - $xml = new DOMDocument(); + $xml = $this->getDomDocument(); $xml->load($path); return $this->getXSLTProcessor()->transformToXml($xml); @@ -142,11 +145,23 @@ class Class_Notice_Xsl { public function getXSLTProcessor() { return static::$_xslt_processor ? static::$_xslt_processor - : new XSLTProcessor(); + : (static::$_xslt_processor = new XSLTProcessor()); } public static function setXSLTProcessor($xslt_processor) { static::$_xslt_processor = $xslt_processor; } + + + public function getDomDocument() { + return static::$_dom_document + ? static::$_dom_document + : new DOMDocument; + } + + + public static function setDomDocument($dom_document) { + static::$_dom_document = $dom_document; + } } \ No newline at end of file diff --git a/tests/scenarios/Xsl/XslTest.php b/tests/scenarios/Xsl/XslTest.php index 0f2bf35d8171f387a0a1b7720674c7f9d917b89f..e95f04f370997e75fadc7e8fbbefd76d192697c0 100644 --- a/tests/scenarios/Xsl/XslTest.php +++ b/tests/scenarios/Xsl/XslTest.php @@ -143,6 +143,12 @@ class XslNoticeajaxDetailDispatchTest extends AbstractControllerTestCase { Class_Notice_Xsl::setPhpCommand($php_command); + $dom_document = $this->mock() + ->whenCalled('load') + ->answers(true); + + Class_Notice_Xsl::setDomDocument($dom_document); + $xslt_processor = $this->mock() ->whenCalled('importStylesheet') ->answers(true)