You are here

public function AggregatorTestBase::updateFeedItems in Drupal 8

Same name in this branch
  1. 8 core/modules/aggregator/src/Tests/AggregatorTestBase.php \Drupal\aggregator\Tests\AggregatorTestBase::updateFeedItems()
  2. 8 core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php \Drupal\Tests\aggregator\Functional\AggregatorTestBase::updateFeedItems()
Same name and namespace in other branches
  1. 9 core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php \Drupal\Tests\aggregator\Functional\AggregatorTestBase::updateFeedItems()

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.

9 calls to AggregatorTestBase::updateFeedItems()
AggregatorDisplayConfigurableTest::testItemDisplayConfigurable in core/modules/aggregator/tests/src/Functional/AggregatorDisplayConfigurableTest.php
Sets item base fields to configurable display and checks settings are respected.
AggregatorRenderingTest::testBlockLinks in core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
Adds a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
Creates a feed and checks that feed's page.
AggregatorTestBase::updateAndDelete in core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
Adds and deletes feed items and ensure that the count is zero.
FeedAdminDisplayTest::testFeedUpdateFields in core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php
Tests the "Next update" and "Last update" fields.

... See full list

File

core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php, line 186

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\Tests\aggregator\Functional

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
    ->assertSession()
    ->statusCodeEquals(200);

  // Attempt to access the update link directly without an access token.
  $this
    ->drupalGet('admin/config/services/aggregator/update/' . $feed
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(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.
  $item_ids = \Drupal::entityQuery('aggregator_item')
    ->condition('fid', $feed
    ->id())
    ->execute();
  $feed->items = array_values($item_ids);
  if ($expected_count !== NULL) {
    $feed->item_count = count($feed->items);
    $this
      ->assertEqual($expected_count, $feed->item_count, new FormattableMarkup('Total items in feed equal to the total items in database (@val1 != @val2)', [
      '@val1' => $expected_count,
      '@val2' => $feed->item_count,
    ]));
  }
}