8.3.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.3.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.0.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.1.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.2.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.4.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)
8.4.x AggregatorTestBase.php public AggregatorTestBase::updateFeedItems(FeedInterface $feed, $expected_count = NULL)

Updates the feed items.

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

Parameters

\Drupal\aggregator\FeedInterface $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 core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Adds a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Creates a feed and checks that feed's page.
AggregatorTestBase::updateAndDelete in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Adds and deletes feed items and ensure that the count is zero.
FeedAdminDisplayTest::testFeedUpdateFields in core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
Tests the "Next update" and "Last update" fields.
FeedFetcherPluginTest::testfetch in core/modules/aggregator/src/Tests/FeedFetcherPluginTest.php
Test fetching functionality.

... See full list

File

core/modules/aggregator/src/Tests/AggregatorTestBase.php, line 165

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\aggregator\Tests

Code

public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
  // First, let's ensure we can get to the rss xml.
  $this->drupalGet($feed->getUrl());
  $this->assertResponse(200, format_string(':url is reachable.', array(':url' => $feed->getUrl())));

  // 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()));
  $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)));
  }
}