- $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
- $this->moduleHandler = new ModuleHandler($this->root, [
+ /**
+ * Get a module handler object to test.
+ *
+ * Since we have to run these tests in separate processes, we have to use
+ * test objects which are serializable. Since ModuleHandler will populate
+ * itself with Extension objects, and since Extension objects will try to
+ * access DRUPAL_ROOT when they're unserialized, we can't store our mocked
+ * ModuleHandler objects as a property in unit tests. They must be generated
+ * by the test method by calling this method.
+ *
+ * @return \Drupal\Core\Extension\ModuleHandler
+ * The module handler to test.
+ */
+ protected function getModuleHandler() {
+ $module_handler = new ModuleHandler($this->root, [