setIntervalFn = function(tick, delay, deferred, skipApply) {
          var id = nextRepeatId++;
          var fn = !skipApply ? tick : function() {
            tick();
            $browser.defer.flush();
          };

          repeatFns.push({
            nextTime: (now + (delay || 0)),
            delay: delay || 1,
            fn: fn,
            id: id,
            deferred: deferred
          });
          repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime; });

          return id;
        }
@ngdoc service
@name $interval

@description
Mock implementation of the $interval service.

Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
move forward by `millis` milliseconds and trigger any functions scheduled to run in that
time.

@param {function()} fn A function that should be called repeatedly.
@param {number} delay Number of milliseconds between each function call.
@param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
  indefinitely.
@param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
  will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
@param {...*=} Pass additional parameters to the executed function.
@returns {promise} A promise which will be notified on each iteration.