public function serializeToXml()
{
$strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<LiveChannelConfiguration>
</LiveChannelConfiguration>
EOF;
$xml = new \SimpleXMLElement($strXml);
if (isset($this->description)) {
$xml->addChild('Description', $this->description);
}
if (isset($this->status)) {
$xml->addChild('Status', $this->status);
}
$node = $xml->addChild('Target');
$node->addChild('Type', $this->type);
if (isset($this->fragDuration)) {
$node->addChild('FragDuration', $this->fragDuration);
}
if (isset($this->fragCount)) {
$node->addChild('FragCount', $this->fragCount);
}
if (isset($this->playListName)) {
$node->addChild('PlayListName', $this->playListName);
}
return $xml->asXML();
}
public function testLiveChannelConfig() { $config = new LiveChannelConfig(array('name' => 'live-1')); $config->parseFromXml($this->config); $this->assertEquals('xxx', $config->getDescription()); $this->assertEquals('enabled', $config->getStatus()); $this->assertEquals('hls', $config->getType()); $this->assertEquals(1000, $config->getFragDuration()); $this->assertEquals(5, $config->getFragCount()); $this->assertEquals('hello.m3u8', $config->getPlayListName()); $xml = $config->serializeToXml(); $config2 = new LiveChannelConfig(array('name' => 'live-2')); $config2->parseFromXml($xml); $this->assertEquals('xxx', $config2->getDescription()); $this->assertEquals('enabled', $config2->getStatus()); $this->assertEquals('hls', $config2->getType()); $this->assertEquals(1000, $config2->getFragDuration()); $this->assertEquals(5, $config2->getFragCount()); $this->assertEquals('hello.m3u8', $config2->getPlayListName()); }