public function testSetGenerator() { $this->fixture->setGenerator(new Atom_Generator('Example toolkit')); $xml=$this->fixture->saveXml(); $temp=Atom_Element::fromXml($xml); $this->assertEquals($xml,$temp->saveXml()); }
public function testPrint() { $xml=$this->fixture->saveXml(); $temp=Atom_Element::fromXml($xml); $this->assertEquals($xml, $temp->saveXML()); }
public function testFromXmlFile2() { $xml = file_get_contents(dirname(__FILE__).'/../fixtures/infos-du-net.xml'); $dom=DOMDocument::loadXML($xml,LIBXML_NOBLANKS); $temp= Atom_Element::fromXmlFile(dirname(__FILE__).'/../fixtures/infos-du-net.xml'); $this->assertEquals($dom->saveXml(), $temp->saveXml()); }
/** * constructor * set up an Atom_Text instance * * @param string $tagName * @param string $text * @param array $attributes * @param boolean $cdata * @access public */ public function __construct($tagName='', $text='', Array $attributes=array(), $cdata=0) { parent::__construct($tagName); $this->setAttributes($attributes); if(array_key_exists('type',$attributes)) { $type=$attributes['type']; /*if($type!='text' && $type!='html' && $type!='xhtml') { throw new Atom_Exception('Invalid type'); }*/ if($text!=null && $text!='') { if($type=='text' || $type=='html') { if(!$cdata) { $temp=$this->createTextNode($text);; $this->documentElement->appendChild($temp); } else { $temp=$this->createCDATASection($text); $this->documentElement->appendChild($temp); } } if($type=='xhtml') { $div=$this->createElement('div'); $this->documentElement->appendChild($div); $div->setAttribute('xmlns','http://www.w3.org/1999/xhtml'); if(!$cdata) { $temp=$this->createTextNode($text);; $div->appendChild($temp); } else { $temp=$this->createCDATASection($text); $div->appendChild($temp); } } } } elseif($text!=null && $text!='') { if(!$cdata) { $temp=$this->createTextNode($text);; $this->documentElement->appendChild($temp); } else { $temp=$this->createCDATASection($text); $this->documentElement->appendChild($temp); } } }
/** * constuctor * set up an Atom_Feed instance * * @param array $attributes * @param boolean $cdata * @access public */ public function __construct(Array $attributes=array(),$cdata=0) { parent::__construct('feed'); if(!array_key_exists('xmlns',$attributes)) { $this->documentElement->setAttribute('xmlns','http://www.w3.org/2005/Atom'); } $this->setAttributes($attributes); }
public function testPrint() { $this->fixture->add(new Atom_Title('Example feed')); $this->fixture->add(new Atom_Author('Jemba','*****@*****.**')); $this->fixture->add(new Atom_Contributor('Rivoallan','*****@*****.**')); $this->fixture->add(new Atom_Category('CPU',array('term'=>'technology'))); $this->fixture->add(new Atom_Updated(new DateTime())); $this->fixture->add(new Atom_Id('urn:uuid:60a76c80-d399-11d9-b93C-5798hnt64')); $this->fixture->add(new Atom_Link('',array('rel'=>'self', 'href'=>'http://www.validome.org/check/RSS_validator/version/atom_1_0/action/xml/feed/400'))); $this->fixture->add(new Atom_Rights('content',array('type'=>'text'))); $xml=$this->fixture->saveXml(); $temp=Atom_Element::fromXml($xml); $this->assertEquals($xml, $temp->saveXML()); }
/** * constructor * set up Atom_Person intance * * @param string $tagName * @param string $name * @param string $email * @param string $uri * @param array $attributes * @access public */ public function __construct($tagName='', $name='', $email='', $uri='', Array $attributes=array()) { parent::__construct($tagName); $this->setAttributes($attributes); if($name!='' && $name!=null) { $this->setName($name); } if($email!='' && $email!=null) { $this->setEmail($email); } if($uri!='' && $uri!=null) { $this->setUri($uri); } }
/** * constructor * set up an Atom_Date instance * * @param string $tagName * @param DateTime $date * @param array $attributes * @param boolean $cdata * @access public */ public function __construct($tagName='', DateTime $date=null, Array $attributes=array(), $cdata=0) { parent::__construct($tagName); $this->setAttributes($attributes); if($date!=null && $date!='') { if(!$cdata) { $temp=$this->createTextNode($date->format(DateTime::ATOM)); $this->documentElement->appendChild($temp); } else { $temp=$this->createCDATASection($date->format(DateTime::ATOM)); $this->documentElement->appendChild($temp); } } }
/** * constructor * set up an Atom_Source instance * * @param array $attributes * @param boolean $cdata * @access public */ public function __construct(Array $attributes=array(),$cdata=0) { parent::__construct('source'); $this->setAttributes($attributes); }
public function testPrintWithNamespaces() { $xml = file_get_contents(dirname(__FILE__).'/../fixtures/content.xml'); $temp=Atom_Element::fromXmlFile(dirname(__FILE__).'/../fixtures/content.xml'); $this->assertEquals($xml, $temp->saveXML()); }
/** * return an Atom_* instance depending on the tag name * * @param string $tagName * @return Atom_* * @access protected */ protected function get($tagName) { if($this->documentElement==null) { return null; } $element=Atom_Element::getInstance($this, $tagName); $element->init($this->documentElement->getElementsByTagName($tagName)->item(0)); return $element; }