function AggregatorTestBase::updateFeedItems

Update feed items (simulate click to admin/config/services/aggregator/update/$fid).

Parameters

$feed: Feed object representing the feed.

$expected_count: Expected number of feed items.

5 calls to AggregatorTestBase::updateFeedItems()
AggregatorRenderingTest::testBlockLinks in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Add a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Create a feed and check that feed's page.
AggregatorTestBase::updateAndRemove in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
Add and remove feed items and ensure that the count is zero.
CategorizeFeedItemTest::testCategorizeFeedItem in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php
If a feed has a category, make sure that the children inherit that categorization.
UpdateFeedItemTest::testUpdateFeedItem in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedItemTest.php
Test running "update items" from the 'admin/config/services/aggregator' page.

File

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

Class

AggregatorTestBase
Defines a base class for testing aggregator.module.

Namespace

Drupal\aggregator\Tests

Code

function updateFeedItems(&$feed, $expected_count) {

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

  // Attempt to access the update link directly without an access token.
  $this
    ->drupalGet('admin/config/services/aggregator/update/' . $feed->fid);
  $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->fid,
  ));
  $items = array();
  $feed->items = array();
  foreach ($result as $item) {
    $feed->items[] = $item->iid;
  }
  $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,
  )));
}