Unit test environment no longer working on windows after latest CodeGen updates
There were some codegen updates to create the sql on the fly instead of loading from files. On windows though the backwards path separators cause the parsing of the xml to not be able to find the files. The call to DomDocument->xinclude() gets confused.
This quick hack makes it work, but doesn't seem like a proper fix. In general php works well on windows when you always use forward slash except when calling out to system calls, so maybe the path could be normalized somewhere higher up the chain. I haven't traced it back where it's getting it from in the first place.
Running the old php GenCode.php
always used to work, so it's something about the environment difference when running in tests where the path is getting mangled.
diff --git a/CRM/Core/CodeGen/Util/Xml.php b/CRM/Core/CodeGen/Util/Xml.php
index 8d64be7006..91710ffe17 100644
--- a/CRM/Core/CodeGen/Util/Xml.php
+++ b/CRM/Core/CodeGen/Util/Xml.php
@@ -15,6 +15,7 @@ class CRM_Core_CodeGen_Util_Xml {
$dom = new DomDocument();
$xmlString = file_get_contents($file);
$dom->loadXML($xmlString);
+ $file = str_replace("\\", '/', $file);
$dom->documentURI = $file;
$dom->xinclude();
$xml = simplexml_import_dom($dom);
Edited by DaveD