/*jshint unused:false, loopfunc:true*/
define([
    'dojo/_base/array',
    'dojo/_base/lang'
],

function (
    array,
    lang
    ) {
    return function (modulePath, stubs, forcedRefreshModules) {
        // inspired by: http://stackoverflow.com/questions/11439540/how-can-i-mock-dependencies-for-unit-testing-in-requirejs
        // and https://github.com/mattfysh/testr.js
        var aliases = [],
            key,
            stubname,
            returnModule,
            clonedAliases;

        require.undef(modulePath);

        // clear out any modules that need to be forced (usually dependencies that use the stubs)
        array.forEach(forcedRefreshModules, function (mod) {
            require.undef(mod);
        });

        // add stubs as aliases
        for (key in stubs) {
            if (stubs.hasOwnProperty(key)) {
                // clear any previously cached object for this alias
                require.undef(key);

                stubname = 'STUB_' + key;

                aliases.push([key, stubname]);

                define(stubname, [], function () {
                    return stubs[key];
                });
            }
        }

        // clone array because passing it in the require config messes with the values
        clonedAliases = lang.clone(aliases);

        // get module with stubs
        require({aliases: clonedAliases}, [modulePath], function (Module) {
            returnModule = Module;
        });

        // remove stub aliases
        array.forEach(require.aliases, function (al, i) {
            if (array.some(clonedAliases, function (cAl) {
                return al[0].test(cAl[0]);
            })) {
                require.aliases.splice(i, 1);
            }
        });

        // clear cache again
        require.undef(modulePath);
        array.forEach(aliases, function (a) {
            require.undef(a[0]);
            require.undef(a[1]);
        });

        return returnModule;
    };
});
@@ -1482,32 +1482,64 @@
 ve stub aliases%0A
+        var removedIndexs = %5B%5D;%0A
         array.fo
@@ -1696,32 +1696,148 @@
       %7D)) %7B%0A    
+            removedIndexs.unshift(i);%0A            %7D%0A        %7D);%0A%0A        array.forEach(removedIndexs, function(i) %7B%0A
             requ
@@ -1861,27 +1861,12 @@
 e(i,
- 
 1);%0A
-            %7D%0A
     

Fix removal of multiple items from alias array