예제 #1
0
 public function testAddItemToAtomandParse()
 {
     $feed = new Atom('Alpha\\Model\\Article', 'Test Feed Title', 'http://www.alphaframework.org/', 'Test Feed Description');
     $feed->setFieldMappings('title', 'URL', 'description', 'created_ts', 'OID');
     $feed->addBO($this->BO);
     $xml = $feed->render();
     $reader = new XMLReader();
     $validXML = $reader->XML($xml);
     $this->assertTrue($validXML, 'Confirming that the generated XML can be parsed correctly');
     $simpleXML = new SimpleXMLElement($xml);
     $simpleXML->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
     $feeds = $simpleXML->xpath('//atom:feed');
     $this->assertEquals('Test Feed Title', (string) $feeds[0]->title, 'Testing that the feed title is present');
     $this->assertEquals('http://www.alphaframework.org/', (string) $feeds[0]->link->attributes()->href, 'Testing that the feed URL is present');
     $items = $simpleXML->xpath('//atom:entry');
     $this->assertEquals('Test Article Title', (string) $items[0]->title, 'Testing that the feed item title is present');
     $this->assertEquals('Test Article Description', (string) $items[0]->summary, 'Testing that the feed item description is present');
     $this->assertEquals('2011-01-01T00:00:00+00:00', (string) $items[0]->updated, 'Testing that the feed item publish time is present');
 }