You are here

public function AutomaticUpdatesTestCase::testAutomaticUpdates in Automatic Updates 7

Test automatic updates.

File

tests/automatic_updates.test, line 45
Contains AutomaticUpdatesTestCase class.

Class

AutomaticUpdatesTestCase
Class AutomaticUpdatesTestCase.

Code

public function testAutomaticUpdates() {

  // Test PSAs.
  $this
    ->drupalGet('admin');
  $this
    ->assertText('Critical Release - SA-2019-02-19');
  $this
    ->assertText('Critical Release - PSA-Really Old');
  $this
    ->assertText('Seven - Moderately critical - Access bypass - SA-CONTRIB-2019');
  $this
    ->assertNoText('Node - Moderately critical - Access bypass - SA-CONTRIB-2019');

  // Test disabling PSAs.
  variable_set('automatic_updates_enable_psa', FALSE);
  $this
    ->drupalGet('admin');
  $this
    ->assertNoText('Critical Release - SA-2019-02-19');
  variable_set('automatic_updates_enable_psa', TRUE);

  // Test site status report.
  $this
    ->drupalGet($this
    ->getAbsoluteUrl('admin/reports/status'));
  $this
    ->assertText('3 urgent announcements require your attention:');

  // Test cache.
  $psa_endpoint = $this
    ->getAbsoluteUrl('automatic_updates/test-json-denied');
  variable_set('automatic_updates_psa_endpoint', $psa_endpoint);
  $this
    ->drupalGet('admin');
  $this
    ->assertText('Critical Release - SA-2019-02-19');

  // Test transmit errors with JSON endpoint.
  cache_clear_all([
    'automatic_updates_psa',
  ], 'cache');
  $this
    ->drupalGet('admin');
  $this
    ->assertText('automatic_updates/test-json-denied is unreachable.');
}