title: AngularJS: Mock object injected to controller trough router's resolve
body: <p>I'm trying to test a controller that receives an object trough router's resolve:</p>
  
  <p><code>app.js</code>:</p>
  
  <pre><code>...
  .when('/confirm', {
    templateUrl: 'views/confirm.html',
    controller: 'ConfirmCtrl',
    resolve: {
      order: function(Order) {
        return Order.current;
      }
    }
  })
  ...
  </code></pre>
  
  <p><code>ConfirmCtrl.js</code>:</p>
  
  <pre><code>angular.module('angularGeolocationApp').controller('ConfirmCtrl',
  function($scope, order, ...) {
  
    $scope.order = order
  
    ...
  
  });
  </code></pre>
  
  <p>My Test looks like this:</p>
  
  <pre><code>'use strict';
  
  describe('Controller: ConfirmCtrl', function () {
  
    // load the controller's module
    beforeEach(module('angularGeolocationApp'));
  
    var ConfirmCtrl,
      scope;
  
    // Initialize the controller and a mock scope
    beforeEach(inject(function ($controller, $rootScope) {
      scope = $rootScope.$new();
      ConfirmCtrl = $controller('ConfirmCtrl', {
        $scope: scope
      });
    }));
  
    it('should get an order object', function () {
      expect(_.isObject(scope.order)).toBeTruthy();
    });
  
    ...
  });
  </code></pre>
  
  <p>However first expectation fails:</p>
  
  <pre><code>PhantomJS 1.9.2 (Mac OS X) Controller: ConfirmCtrl should get an order object FAILED
      TypeError: Attempted to assign to readonly property.
          at workFn (/Users/jviotti/Projects/Temporal/angular/angular-geolocation/app/bower_components/angular-mocks/angular-mocks.js:2107)
      Expected false to be truthy.
  </code></pre>
  
  <p>My assumption is that as I'm unit testing the isolated controller, the router doesn't have a change to run the resolve function and assign the correct value.</p>
  
  <p>Is there a way to mock that <code>order</code> dependency?</p>
  
  <p>I know I can get rid of the resolve stuff and inject <code>Order</code> and instantiate <code>$scope.order</code> to <code>Order.current</code> in the controller itself, but I'd like to keep the <code>resolve</code> approach.</p>