Skip to content
Snippets Groups Projects
Commit 1826dfb4 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #73871 wrap DOMDocument for tests

parent 83574107
Branches
Tags
5 merge requests!2660Master,!2616Dev#73871 minsoc xlst etape 2 association fichier xslt,!2601Dev#73871 minsoc xlst etape 2 association fichier xslt,!2597Dev#73871 minsoc xlst etape 2 association fichier xslt,!2589Dev#73871 minsoc xlst etape 2 association fichier xslt
Pipeline #3894 passed with stage
in 49 minutes and 2 seconds
......@@ -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
......@@ -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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment