\n" .
"\n" .
" test\n" .
" 1\n" .
"\n";
public function testParseXml()
{
$res = XML::parseXml($this->xmlStr, new tests());
$name = $res['name'];
$value = $res['value'];
$this->assertEquals('test', $name);
$this->assertEquals('1', $value);
$res = XML::parseXml($this->xmlStr, null);
$name = $res['name'];
$value = $res['value'];
$this->assertEquals('test', $name);
$this->assertEquals('1', $value);
}
public function testArrayToXML()
{
$data = [
'tests' => [
'name' => 'test',
'value' => 1,
],
];
$this->assertEquals("\ntest1", XML::toXML($data));
}
public function testObjectToXML()
{
$obj = new tests();
$obj->name = 'test';
$obj->value = 1;
$this->assertEquals("\ntest1", XML::toXML($obj));
}
}
class tests
{
public $name = '';
public $value = 0;
}