Backup of db before drupal security update
[yaffs-website] / web / core / modules / aggregator / tests / src / Functional / AggregatorCronTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Functional;
4
5 use Drupal\Tests\Traits\Core\CronRunTrait;
6
7 /**
8  * Update feeds on cron.
9  *
10  * @group aggregator
11  */
12 class AggregatorCronTest extends AggregatorTestBase {
13
14   use CronRunTrait;
15
16   /**
17    * Adds feeds and updates them via cron process.
18    */
19   public function testCron() {
20     // Create feed and test basic updating on cron.
21     $this->createSampleNodes();
22     $feed = $this->createFeed();
23     $this->cronRun();
24     $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
25     $this->deleteFeedItems($feed);
26     $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
27     $this->cronRun();
28     $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
29
30     // Test feed locking when queued for update.
31     $this->deleteFeedItems($feed);
32     db_update('aggregator_feed')
33       ->condition('fid', $feed->id())
34       ->fields([
35         'queued' => REQUEST_TIME,
36       ])
37       ->execute();
38     $this->cronRun();
39     $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
40     db_update('aggregator_feed')
41       ->condition('fid', $feed->id())
42       ->fields([
43         'queued' => 0,
44       ])
45       ->execute();
46     $this->cronRun();
47     $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
48   }
49
50 }