public function __construct() { $cfg = PathResolver::getInstance()->getPath("{APP}/config/routes.sdl"); if (!file_exists($cfg) || !is_readable($cfg)) { \debug("Could not read routelist from {$cfg}."); } else { $root = new SdlTag(); $root->loadFile($cfg); $this->routes = $root->query("/routes/route"); $num = count($this->routes); \debug("Parsed {$num} routes from {$cfg}"); } }
public function testReadFile() { $fnam = tempnam("/tmp", "phpunit"); $sdl = <<<EOT // tag comment sdl:tag { // foo comment foo "value1" "value2" "value3" attr1="string" attr2=true attr3=null // bar comment bar "value1" // baz comment baz attr="value" } EOT; file_put_contents($fnam, $sdl); $node = new SdlTag("root"); $node->loadFile($fnam); $enc = $node->getChild(0)->encode(); $this->assertEquals(trim($sdl), trim($enc), "Encoded data does not match decoded data"); }