text: import { Promise } from 'rsvp';
  import legacyBuildRegistry from 'ember-test-helpers/legacy-0-6-x/build-registry';
  /**
    Creates an "owner" (an object that either _is_ or duck-types like an
    `Ember.ApplicationInstance`) from the provided options.
  
    If `options.application` is present (e.g. setup by an earlier call to
    `setApplication`) an `Ember.ApplicationInstance` is built via
    `application.buildInstance()`.
  
    If `options.application` is not present, we fall back to using
    `options.resolver` instead (setup via `setResolver`). This creates a mock
    "owner" by using a custom created combination of `Ember.Registry`,
    `Ember.Container`, `Ember._ContainerProxyMixin`, and
    `Ember._RegistryProxyMixin`.
  
    @private
    @param {Ember.Application} [application] the Ember.Application to build an instance from
    @param {Ember.Resolver} [resolver] the resolver to use to back a "mock owner"
    @returns {Promise<Ember.ApplicationInstance>} a promise resolving to the generated "owner"
  */
  export default function buildOwner(application, resolver) {
      if (application) {
          return application.boot().then(app => app.buildInstance().boot());
      }
      if (!resolver) {
          throw new Error('You must set up the ember-test-helpers environment with either `setResolver` or `setApplication` before running any tests.');
      }
      let { owner } = legacyBuildRegistry(resolver);
      return Promise.resolve(owner);
  }
  