public function testSaveToString() { $xmldoc = new TXmlDocument('1.0', 'utf-8'); $xmldoc->setTagName('root'); $node = new TXmlElement('node'); $node->setAttribute('param', 'attribute1'); $xmldoc->getElements()->add($node); $xmlString = $xmldoc->saveToString(); // test magic method $magicString = (string) $xmldoc; self::assertEquals($magicString, $xmlString); // Result string should be : $resultString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <node param=\"attribute1\"\n</root>"; self::assertEquals($xmlString, $magicString); }