You are here

public function FeedParserTest::testAtomSample in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/tests/src/Functional/FeedParserTest.php \Drupal\Tests\aggregator\Functional\FeedParserTest::testAtomSample()

Tests a feed that uses the Atom format.

File

core/modules/aggregator/tests/src/Functional/FeedParserTest.php, line 59

Class

FeedParserTest
Tests the built-in feed parser with valid feed samples.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function testAtomSample() {
  $feed = $this
    ->createFeed($this
    ->getAtomSample());
  $feed
    ->refreshItems();
  $this
    ->drupalGet('aggregator/sources/' . $feed
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertText('Atom-Powered Robots Run Amok');
  $this
    ->assertLinkByHref('http://example.org/2003/12/13/atom03');
  $this
    ->assertText('Some text.');
  $item_ids = \Drupal::entityQuery('aggregator_item')
    ->condition('link', 'http://example.org/2003/12/13/atom03')
    ->execute();
  $item = Item::load(array_values($item_ids)[0]);
  $this
    ->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $item
    ->getGuid(), 'Atom entry id element is parsed correctly.');

  // Check for second feed entry.
  $this
    ->assertText('We tried to stop them, but we failed.');
  $this
    ->assertLinkByHref('http://example.org/2003/12/14/atom03');
  $this
    ->assertText('Some other text.');
  $item_ids = \Drupal::entityQuery('aggregator_item')
    ->condition('link', 'http://example.org/2003/12/14/atom03')
    ->execute();
  $item = Item::load(array_values($item_ids)[0]);
  $this
    ->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $item
    ->getGuid(), 'Atom entry id element is parsed correctly.');
}