automatic_updates.test 2.46 KB
Newer Older
1
2
<?php

3
4
5
6
7
8
9
10
/**
 * @file
 * Contains AutomaticUpdatesTestCase class.
 */

/**
 * Class AutomaticUpdatesTestCase.
 */
11
class AutomaticUpdatesTestCase extends DrupalWebTestCase {
12
13
14
15

  /**
   * {@inheritdoc}
   */
16
17
18
19
  public static function getInfo() {
    return array(
      'name' => 'Automatic Updates',
      'description' => 'Tests automatic updates.',
20
      'group' => 'Automatic Updates',
21
22
23
24
    );
  }

  /**
25
   * {@inheritdoc}
26
   */
27
28
  public function setUp() {
    parent::setUp(array('automatic_updates', 'automatic_updates_test'));
29
    // Create a user with permission to view the actions administration pages.
30
31
32
33
34
    $user = $this->drupalCreateUser(array(
      'access administration pages',
      'administer site configuration',
      'administer software updates',
    ));
35
    $this->drupalLogin($user);
36
37
    $psa_endpoint = $this->getAbsoluteUrl('automatic_updates/test-json');
    variable_set('automatic_updates_psa_endpoint', $psa_endpoint);
38
    variable_set('automatic_updates_enable_psa', TRUE);
39
40
41
42
43
44
  }

  /**
   * Test automatic updates.
   */
  public function testAutomaticUpdates() {
45
    // Test PSAs.
46
    $this->drupalGet('admin');
47
48
49
50
51
52
    $this->assertText('Drupal Core PSA: Critical Release - PSA-2019-02-19');
    $this->assertNoText('Drupal Core PSA: Critical Release - PSA-Really Old');
    $this->assertNoText('Node - Moderately critical - Access bypass - SA-CONTRIB-2019');
    $this->assertText('Drupal Contrib Project PSA: Standard - Moderately critical - Access bypass - SA-CONTRIB-2019');
    $this->assertText('Drupal Contrib Project PSA: Seven - Moderately critical - Access bypass - SA-CONTRIB-2019');

53
54
55
56
57
58
    // Test disabling PSAs.
    variable_set('automatic_updates_enable_psa', FALSE);
    $this->drupalGet('admin');
    $this->assertNoText('Drupal Core PSA: Critical Release - PSA-2019-02-19');
    variable_set('automatic_updates_enable_psa', TRUE);

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

63
    // Test cache.
64
65
66
    $psa_endpoint = $this->getAbsoluteUrl('automatic_updates/test-json-denied');
    variable_set('automatic_updates_psa_endpoint', $psa_endpoint);
    $this->drupalGet('admin');
67
68
69
70
    $this->assertText('Drupal Core PSA: Critical Release - PSA-2019-02-19');

    // Test transmit errors with JSON endpoint.
    drupal_flush_all_caches();
71
    $this->drupalGet('admin');
72
    $this->assertText('automatic_updates/test-json-denied is unreachable.');
73
  }
74

75
}