function SecurityAdvisoriesFetcherTest::testIntervalConfigUpdate
Same name in other branches
- 10 core/modules/system/tests/src/Kernel/SecurityAdvisories/SecurityAdvisoriesFetcherTest.php \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest::testIntervalConfigUpdate()
- 11.x core/modules/system/tests/src/Kernel/SecurityAdvisories/SecurityAdvisoriesFetcherTest.php \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest::testIntervalConfigUpdate()
Tests that the stored advisories response is deleted on interval decrease.
File
-
core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php, line 536
Class
- SecurityAdvisoriesFetcherTest
- @coversDefaultClass \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher
Namespace
Drupal\Tests\system\Kernel\SecurityAdvisoriesCode
public function testIntervalConfigUpdate() : void {
$feed_item_1 = [
'is_psa' => 1,
'type' => 'core',
'title' => 'Oh no🙀! Advisory 1',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
];
$feed_item_2 = [
'is_psa' => 1,
'type' => 'core',
'title' => 'Oh no😱! Advisory 2',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
];
$this->setFeedItems([
$feed_item_1,
$feed_item_2,
]);
$advisories = $this->getAdvisories();
$this->assertCount(1, $advisories);
$this->assertSame($feed_item_1['title'], $advisories[0]->getTitle());
$this->assertCount(1, $this->history);
// Ensure that new feed item is not retrieved because the stored response
// has not expired.
$advisories = $this->getAdvisories();
$this->assertCount(1, $this->history);
$this->assertCount(1, $advisories);
$this->assertSame($feed_item_1['title'], $advisories[0]->getTitle());
/** @var \Drupal\Core\Config\Config $config */
$config = $this->container
->get('config.factory')
->getEditable('system.advisories');
$interval = $config->get('interval_hours');
$config->set('interval_hours', $interval + 1)
->save();
// Ensure that new feed item is not retrieved when the interval is
// increased.
$advisories = $this->getAdvisories();
$this->assertCount(1, $this->history);
$this->assertCount(1, $advisories);
$this->assertSame($feed_item_1['title'], $advisories[0]->getTitle());
// Ensure that new feed item is retrieved when the interval is decreased.
$config->set('interval_hours', $interval - 1)
->save();
$advisories = $this->getAdvisories();
$this->assertCount(2, $this->history);
$this->assertCount(1, $advisories);
$this->assertSame($feed_item_2['title'], $advisories[0]->getTitle());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.