public function AggregatorCronTest::testCron in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/aggregator/src/Tests/AggregatorCronTest.php \Drupal\aggregator\Tests\AggregatorCronTest::testCron()
Adds feeds and updates them via cron process.
File
- core/
modules/ aggregator/ src/ Tests/ AggregatorCronTest.php, line 19 - Contains \Drupal\aggregator\Tests\AggregatorCronTest.
Class
- AggregatorCronTest
- Update feeds on cron.
Namespace
Drupal\aggregator\TestsCode
public function testCron() {
// Create feed and test basic updating on cron.
$this
->createSampleNodes();
$feed = $this
->createFeed();
$this
->cronRun();
$this
->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $feed
->id(),
))
->fetchField());
$this
->deleteFeedItems($feed);
$this
->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $feed
->id(),
))
->fetchField());
$this
->cronRun();
$this
->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $feed
->id(),
))
->fetchField());
// Test feed locking when queued for update.
$this
->deleteFeedItems($feed);
db_update('aggregator_feed')
->condition('fid', $feed
->id())
->fields(array(
'queued' => REQUEST_TIME,
))
->execute();
$this
->cronRun();
$this
->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $feed
->id(),
))
->fetchField());
db_update('aggregator_feed')
->condition('fid', $feed
->id())
->fields(array(
'queued' => 0,
))
->execute();
$this
->cronRun();
$this
->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $feed
->id(),
))
->fetchField());
}