Beispiel #1
0
 public function testFeedURLFallbackIsUsed()
 {
     $parser = new Atom(file_get_contents('tests/fixtures/atom_empty_feed.xml'), '', 'https://feeds.wikipedia.org/category/Russian-language_literature.xml');
     $feed = $parser->execute();
     $this->assertEquals('https://feeds.wikipedia.org/category/Russian-language_literature.xml', $feed->getFeedUrl());
 }
 public function testItemContent()
 {
     $parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
     $feed = $parser->execute();
     $this->assertNotEmpty($feed->items);
     $this->assertTrue(strpos($feed->items[1]->getContent(), '<p>Technology can') === 0);
     $parser = new Atom(file_get_contents('tests/fixtures/atomsample.xml'));
     $feed = $parser->execute();
     $this->assertNotEmpty($feed->items);
     $this->assertTrue(strpos($feed->items[0]->getContent(), '<p>Some text.') === 0);
 }
Beispiel #3
0
 public function testFindItemEnclosure()
 {
     $parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
     $feed = $parser->execute();
     $this->assertEquals('https://upload.wikimedia.org/wikipedia/commons/4/41/War-and-peace_1873.gif', $feed->items[0]->getEnclosureUrl());
     $this->assertEquals('image/gif', $feed->items[0]->getEnclosureType());
     $parser = new Atom(file_get_contents('tests/fixtures/atom_no_default_namespace.xml'));
     $feed = $parser->execute();
     $this->assertEquals('https://upload.wikimedia.org/wikipedia/commons/4/41/War-and-peace_1873.gif', $feed->items[0]->getEnclosureUrl());
     $this->assertEquals('image/gif', $feed->items[0]->getEnclosureType());
     $parser = new Atom(file_get_contents('tests/fixtures/atom_prefixed.xml'));
     $feed = $parser->execute();
     $this->assertEquals('https://upload.wikimedia.org/wikipedia/commons/4/41/War-and-peace_1873.gif', $feed->items[0]->getEnclosureUrl());
     $this->assertEquals('image/gif', $feed->items[0]->getEnclosureType());
     $parser = new Atom(file_get_contents('tests/fixtures/atom_empty_item.xml'));
     $feed = $parser->execute();
     $this->assertEquals('', $feed->items[0]->getEnclosureUrl());
     $this->assertEquals('', $feed->items[0]->getEnclosureType());
 }