public function testSimpleMap() { $created = "143513451"; $rootTopic = new Topic("Central", $created); $subTopicA = new Topic("A", $created); $subTopicB = new Topic("B", $created); $rootTopic->addSub($subTopicA); $rootTopic->addSub($subTopicB); $doc = new Document("Document1", $rootTopic, $created); $json = (new Exporter())->export($doc); //file_put_contents(__DIR__."/Fixture/expected.json", $json); $this->assertJsonStringEqualsJsonFile(__DIR__ . "/Fixture/expected.json", $json); }
private function processNode(\DOMElement $node, \DOMXpath $xpath) { $title = $node->getAttribute("TEXT"); $topic = new Topic($title); $childNodes = $xpath->query("./node", $node); foreach ($childNodes as $childNode) { $subTopic = $this->processNode($childNode, $xpath); $topic->addSub($subTopic); } return $topic; }