UpdatesWith7xTest.php 1.74 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\system\Tests\Update\UpdatesWith7xTest.
6 7 8 9 10 11 12 13 14
 */

namespace Drupal\system\Tests\Update;

use Drupal\simpletest\WebTestBase;

/**
 * Tests for missing update dependencies.
 */
15
class UpdatesWith7xTest extends WebTestBase {
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('update_test_with_7x');

  /**
   * The URL for the update page.
   */
  private $update_url;

  /**
   * An administrative user.
   */
  private $update_user;

  public static function getInfo() {
    return array(
      'name' => '7.x update hooks',
      'description' => 'Tests that the minimum schema version is correct even if only 7.x update hooks are retained .',
      'group' => 'Update API',
    );
  }

  function setUp() {
    parent::setUp();
    require_once DRUPAL_ROOT . '/core/includes/update.inc';
    $this->update_url = $GLOBALS['base_url'] . '/core/update.php';
    $this->update_user = $this->drupalCreateUser(array('administer software updates'));
  }

  function testWith7x() {
    // Ensure that the minimum schema version is 8000, despite 7200 update
    // hooks and a 7XXX hook_update_last_removed().
    $this->assertEqual(drupal_get_installed_schema_version('update_test_with_7x'), 8000);

    // Try to manually set the schema version to 7110 and ensure that no
    // updates are allowed.
    drupal_set_installed_schema_version('update_test_with_7x', 7110);

    // Click through update.php with 'administer software updates' permission.
    $this->drupalLogin($this->update_user);
    $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
    $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
  }
}