Issue #1460764 by klausi: Missing test coverage for a D7 install with non-required...
authorcatch
Mon, 17 Sep 2012 11:30:00 +0000 (12:30 +0100)
committercatch
Mon, 17 Sep 2012 11:30:00 +0000 (12:30 +0100)
core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php [new file with mode: 0644]
core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php [new file with mode: 0644]

diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
new file mode 100644 (file)
index 0000000..c4c6f75
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\system\Tests\Upgrade\ModulesDisabledUpgradePathTest.
+ */
+
+namespace Drupal\system\Tests\Upgrade;
+
+/**
+ * Tests upgrading with all non-required modules installed but disabled.
+ *
+ * Loads a filled installation of Drupal 7 with disabled modules and runs the
+ * upgrade process on it.
+ */
+class ModulesDisabledUpgradePathTest extends UpgradePathTestBase {
+  public static function getInfo() {
+    return array(
+      'name'  => 'Modules disabled upgrade test',
+      'description'  => 'Upgrade path test for disabled modules.',
+      'group' => 'Upgrade path',
+    );
+  }
+
+  public function setUp() {
+    $this->databaseDumpFiles = array(
+      drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.filled.standard_all.database.php.gz',
+      drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.all-disabled.database.php',
+    );
+    parent::setUp();
+  }
+
+  /**
+   * Tests an upgrade with all non-required modules installed but disabled.
+   */
+  public function testDisabledUpgrade() {
+    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
+
+    // Get enabled modules.
+    $enabled = module_list();
+    // Get all available modules.
+    $available = system_rebuild_module_data();
+    // Filter out hidden test modules.
+    foreach ($available as $module => $data) {
+      if (!empty($data->info['hidden'])) {
+        unset($available[$module]);
+      }
+    }
+    $to_enable = array_diff_key($available, $enabled);
+    module_enable(array_keys($to_enable));
+    // Check for updates.
+    require_once DRUPAL_ROOT . '/core/includes/update.inc';
+    require_once DRUPAL_ROOT . '/core/includes/install.inc';
+    $updates = update_get_update_list();
+    $this->assertEqual($updates, array(), 'No pending updates after enabling all modules.');
+  }
+}
diff --git a/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php b/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php
new file mode 100644 (file)
index 0000000..26b819e
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * @file
+ * Database additions for upgrade path tests when all non-required modules are
+ * disabled.
+ *
+ * The drupal-7.filled.standard_all.database.php file is imported before
+ * this dump, so the two form the database structure expected in tests
+ * altogether.
+ */
+
+db_update('system')
+  ->fields(array(
+    'status' => 0,
+  ))
+  ->condition('type', 'module')
+  ->condition('name', array('filter', 'field', 'field_sql_storage', 'entity',
+    'system', 'text', 'user'), 'NOT IN')
+  ->execute();