function AggregatorTestBase::updateFeedItems

Updates the feed items.

This method simulates a click to admin/config/services/aggregator/update/$fid.

Parameters

\Drupal\aggregator\Plugin\Core\Entity\Feed $feed: Feed object representing the feed.

int|null $expected_count: Expected number of feed items. If omitted no check will happen.

8 calls to AggregatorTestBase::updateFeedItems()
AggregatorRenderingTest::testBlockLinks in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Adds a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Creates a feed and checks that feed's page.
AggregatorTestBase::updateAndRemove in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
Adds and removes feed items and ensure that the count is zero.
CategorizeFeedItemTest::testCategorizeFeedItem in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php
Checks that children of a feed inherit a defined category.
FeedFetcherPluginTest::testfetch in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedFetcherPluginTest.php
Test fetching functionality.

... See full list

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php, line 155
Definition of Drupal\aggregator\Tests\AggregatorTestBase.

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\aggregator\Tests

Code

function updateFeedItems(Feed $feed, $expected_count = NULL) {

  // First, let's ensure we can get to the rss xml.
  $this
    ->drupalGet($feed->url->value);
  $this
    ->assertResponse(200, format_string('!url is reachable.', array(
    '!url' => $feed->url->value,
  )));

  // Attempt to access the update link directly without an access token.
  $this
    ->drupalGet('admin/config/services/aggregator/update/' . $feed
    ->id());
  $this
    ->assertResponse(403);

  // Refresh the feed (simulated link click).
  $this
    ->drupalGet('admin/config/services/aggregator');
  $this
    ->clickLink('Update items');

  // Ensure we have the right number of items.
  $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(
    ':fid' => $feed
      ->id(),
  ));
  $items = array();
  $feed->items = array();
  foreach ($result as $item) {
    $feed->items[] = $item->iid;
  }
  if ($expected_count !== NULL) {
    $feed->item_count = count($feed->items);
    $this
      ->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 != !val2)', array(
      '!val1' => $expected_count,
      '!val2' => $feed->item_count,
    )));
  }
}