public function AggregatorRenderingTest::testFeedPage

Creates a feed and checks that feed's page.

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php, line 83
Definition of Drupal\aggregator\Tests\AggregatorRenderingTest.

Class

AggregatorRenderingTest
Tests rendering functionality in the Aggregator module.

Namespace

Drupal\aggregator\Tests

Code

public function testFeedPage() {

  // Increase the number of items published in the rss.xml feed so we have
  // enough articles to test paging.
  $view = entity_load('view', 'frontpage');
  $display =& $view
    ->getDisplay('feed_1');
  $display['display_options']['pager']['options']['items_per_page'] = 30;
  $view
    ->save();

  // Create a feed with 30 items.
  $this
    ->createSampleNodes(30);
  $feed = $this
    ->createFeed();
  $this
    ->updateFeedItems($feed, 30);

  // Check for presence of an aggregator pager.
  $this
    ->drupalGet('aggregator');
  $elements = $this
    ->xpath("//ul[@class=:class]", array(
    ':class' => 'pager',
  ));
  $this
    ->assertTrue(!empty($elements), 'Individual source page contains a pager.');

  // Check for sources page title.
  $this
    ->drupalGet('aggregator/sources');
  $titles = $this
    ->xpath('//h1[normalize-space(text())=:title]', array(
    ':title' => 'Sources',
  ));
  $this
    ->assertTrue(!empty($titles), 'Source page contains correct title.');

  // Find the expected read_more link on the sources page.
  $href = 'aggregator/sources/' . $feed
    ->id();
  $links = $this
    ->xpath('//a[@href = :href]', array(
    ':href' => url($href),
  ));
  $this
    ->assertTrue(isset($links[0]), String::format('Link to href %href found.', array(
    '%href' => $href,
  )));

  // Check for the presence of a pager.
  $this
    ->drupalGet('aggregator/sources/' . $feed
    ->id());
  $elements = $this
    ->xpath("//ul[@class=:class]", array(
    ':class' => 'pager',
  ));
  $this
    ->assertTrue(!empty($elements), 'Individual source page contains a pager.');
}