BareMinimalUpgradePathTest.php 3.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?php

/**
 * @file
 * Definition of Drupal\system\Tests\Upgrade\BareMinimalUpgradePathTest.
 */

namespace Drupal\system\Tests\Upgrade;

/**
 * Performs major version release upgrade tests on a bare database.
 *
 * Loads an installation of Drupal 7.x and runs the upgrade process on it.
 *
 * The install contains the minimal profile modules (without any generated
 * content) so that an upgrade from of a site under this profile may be tested.
 */
class BareMinimalUpgradePathTest extends UpgradePathTestBase {
  public static function getInfo() {
    return array(
      'name'  => 'Basic minimal profile upgrade path, bare database',
      'description'  => 'Basic upgrade path tests for a minimal profile install with a bare database.',
      'group' => 'Upgrade path',
    );
  }

  public function setUp() {
    // Path to the database dump files.
    $this->databaseDumpFiles = array(
      drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.minimal.database.php.gz',
    );
    parent::setUp();
  }

  /**
   * Tests a successful major version release upgrade.
   */
  public function testBasicMinimalUpgrade() {
39
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
40 41 42 43 44 45 46 47

    // Hit the frontpage.
    $this->drupalGet('');
    $this->assertResponse(200);

    // Verify that we are still logged in.
    $this->drupalGet('user');
    $this->clickLink(t('Edit'));
48
    $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), 'We are still logged in as admin at the end of the upgrade.');
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

    // Logout and verify that we can login back in with our initial password.
    $this->drupalLogout();
    $this->drupalLogin((object) array(
      'uid' => 1,
      'name' => 'admin',
      'pass_raw' => 'drupal',
    ));

    // The previous login should've triggered a password rehash, so login one
    // more time to make sure the new hash is readable.
    $this->drupalLogout();
    $this->drupalLogin((object) array(
      'uid' => 1,
      'name' => 'admin',
      'pass_raw' => 'drupal',
    ));

    // Test that the site name is correctly displayed.
68
    $this->assertText('drupal', 'The site name is correctly displayed.');
69 70 71 72 73 74 75 76 77

    // Verify that the main admin sections are available.
    $this->drupalGet('admin');
    $this->assertText(t('Content'));
    $this->assertText(t('Appearance'));
    $this->assertText(t('People'));
    $this->assertText(t('Configuration'));
    $this->assertText(t('Reports'));
    $this->assertText(t('Structure'));
78
    $this->assertText(t('Extend'));
79 80 81

    // Confirm that no {menu_links} entry exists for user/autocomplete.
    $result = db_query('SELECT COUNT(*) FROM {menu_links} WHERE link_path = :user_autocomplete', array(':user_autocomplete' => 'user/autocomplete'))->fetchField();
82
    $this->assertFalse($result, 'No {menu_links} entry exists for user/autocomplete');
83 84

    // Verify that all required modules are enabled.
85
    $enabled = module_list();
86 87 88 89
    $required = array_filter(system_rebuild_module_data(), function ($data) {
      return !empty($data->info['required']);
    });
    $this->assertEqual(array_diff_key($required, $enabled), array());
90
  }
91

92
}