public function AutomaticUpdatesTest::testPsa in Automatic Updates 8
Tests that a PSA is displayed.
File
- tests/
src/ Functional/ AutomaticUpdatesTest.php, line 52
Class
- AutomaticUpdatesTest
- Tests of automatic updates.
Namespace
Drupal\Tests\automatic_updates\FunctionalCode
public function testPsa() {
// Setup test PSA endpoint.
$end_point = $this
->buildUrl(Url::fromRoute('test_automatic_updates.json_test_controller'));
$this
->config('automatic_updates.settings')
->set('psa_endpoint', $end_point)
->save();
$this
->drupalGet(Url::fromRoute('system.admin'));
$this
->assertSession()
->pageTextContains('Critical Release - SA-2019-02-19');
$this
->assertSession()
->pageTextContains('Critical Release - PSA-Really Old');
$this
->assertSession()
->pageTextNotContains('Node - Moderately critical - Access bypass - SA-CONTRIB-2019');
$this
->assertSession()
->pageTextNotContains('Views - Moderately critical - Access bypass - SA-CONTRIB-2019');
// Test site status report.
$this
->drupalGet(Url::fromRoute('system.status'));
$this
->assertSession()
->pageTextContains('3 urgent announcements require your attention:');
// Test cache.
$end_point = $this
->buildUrl(Url::fromRoute('test_automatic_updates.json_test_denied_controller'));
$this
->config('automatic_updates.settings')
->set('psa_endpoint', $end_point)
->save();
$this
->drupalGet(Url::fromRoute('system.admin'));
$this
->assertSession()
->pageTextContains('Critical Release - SA-2019-02-19');
// Test transmit errors with JSON endpoint.
drupal_flush_all_caches();
$this
->drupalGet(Url::fromRoute('system.admin'));
$this
->assertSession()
->pageTextContains("Drupal PSA endpoint {$end_point} is unreachable.");
// Test disabling PSAs.
$end_point = $this
->buildUrl(Url::fromRoute('test_automatic_updates.json_test_controller'));
$this
->config('automatic_updates.settings')
->set('psa_endpoint', $end_point)
->set('enable_psa', FALSE)
->save();
drupal_flush_all_caches();
$this
->drupalGet(Url::fromRoute('system.admin'));
$this
->assertSession()
->pageTextNotContains('Critical Release - PSA-2019-02-19');
$this
->drupalGet(Url::fromRoute('system.status'));
$this
->assertSession()
->pageTextNotContains('urgent announcements require your attention');
}