Пример #1
0
 public function testAddItemToRSS2andParse()
 {
     $feed = new RSS2('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);
     $channels = $simpleXML->xpath('channel');
     $this->assertEquals('Test Feed Title', (string) $channels[0]->title, 'Testing that the feed title is present');
     $this->assertEquals('http://www.alphaframework.org/', (string) $channels[0]->link, 'Testing that the feed URL is present');
     $items = $simpleXML->xpath('channel/item');
     $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]->description, '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');
 }