You are here

public function AggregatorCronTest::testCron in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php \Drupal\Tests\aggregator\Functional\AggregatorCronTest::testCron()

Adds feeds and updates them via cron process.

File

core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php, line 24

Class

AggregatorCronTest
Update feeds on cron.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function testCron() {

  // Create feed and test basic updating on cron.
  $this
    ->createSampleNodes();
  $feed = $this
    ->createFeed();
  $count_query = \Drupal::entityQuery('aggregator_item')
    ->condition('fid', $feed
    ->id())
    ->count();
  $this
    ->cronRun();
  $this
    ->assertEqual(5, $count_query
    ->execute());
  $this
    ->deleteFeedItems($feed);
  $this
    ->assertEqual(0, $count_query
    ->execute());
  $this
    ->cronRun();
  $this
    ->assertEqual(5, $count_query
    ->execute());

  // Test feed locking when queued for update.
  $this
    ->deleteFeedItems($feed);
  $feed
    ->setQueuedTime(REQUEST_TIME)
    ->save();
  $this
    ->cronRun();
  $this
    ->assertEqual(0, $count_query
    ->execute());
  $feed
    ->setQueuedTime(0)
    ->save();
  $this
    ->cronRun();
  $this
    ->assertEqual(5, $count_query
    ->execute());
}