Beispiel #1
0
 /**
  * @covers ByJG\Util\XmlUtil::createChild
  * @covers ByJG\Util\XmlUtil::createChildBefore
  * @covers ByJG\Util\XmlUtil::createChildBeforeNode
  */
 public function testCreateChild()
 {
     $dom = XmlUtil::createXmlDocumentFromStr('<root/>');
     $node = XmlUtil::createChild($dom->documentElement, 'test1');
     XmlUtil::createChild($node, 'test2', 'text2');
     $node2 = XmlUtil::createChild($node, 'test3', 'text3', 'http://opensource.byjg.com');
     $this->assertEquals(self::XMLHEADER . "\n" . '<root>' . '<test1>' . '<test2>text2</test2>' . '<test3 xmlns="http://opensource.byjg.com">text3</test3>' . '</test1>' . '</root>' . "\n", $dom->saveXML());
     XmlUtil::createChildBeforeNode('test1_2', 'text1-2', $node2);
     $this->assertEquals(self::XMLHEADER . "\n" . '<root>' . '<test1>' . '<test2>text2</test2>' . '<test1_2>text1-2</test1_2>' . '<test3 xmlns="http://opensource.byjg.com">text3</test3>' . '</test1>' . '</root>' . "\n", $dom->saveXML());
     XmlUtil::createChildBefore($node, 'testBefore', 'textBefore');
     $this->assertEquals(self::XMLHEADER . "\n" . '<root>' . '<test1>' . '<testBefore>textBefore</testBefore>' . '<test2>text2</test2>' . '<test1_2>text1-2</test1_2>' . '<test3 xmlns="http://opensource.byjg.com">text3</test3>' . '</test1>' . '</root>' . "\n", $dom->saveXML());
 }