src/aria/jsunit/Assert.js
function (initialClass, mockClass) {
                if (this._overriddenClasses == null) {
                    this._overriddenClasses = {};
                }
                var cacheKey = Aria.getLogicalPath(initialClass, ".js", true);
                var clsInfos = this._overriddenClasses[initialClass];
                if (clsInfos == null) { // only save the previous class if it was not already overridden
                    var currentClass = Aria.nspace(initialClass);
                    if (currentClass == null) {
                        return; // invalid namespace
                    }
                    var idx = initialClass.lastIndexOf('.');
                    if (idx > -1) {
                        clsInfos = {
                            clsNs : initialClass.slice(0, idx),
                            clsName : initialClass.slice(idx + 1),
                            initialClass : currentClass
                        };
                    } else {
                        clsInfos = {
                            clsNs : '',
                            clsName : initialClass,
                            initialClass : currentClass
                        };
                    }
                    clsInfos.cachedModule = require.cache[cacheKey];
                    this._overriddenClasses[initialClass] = clsInfos;
                }

                // alter the global classpath to point to the mock
                var ns = Aria.nspace(clsInfos.clsNs);
                ns[clsInfos.clsName] = mockClass;

                // also alter require cache
                delete require.cache[cacheKey];
                var currentContext = require("noder-js/currentContext");
                var modull;
                if (currentContext) {
                    modull = currentContext.getModule(cacheKey);
                } else {
                    modull = {
                        id : cacheKey,
                        filename : cacheKey
                    };
                    require.cache[cacheKey] = modull;
                }
                modull.exports = mockClass;
                modull.loaded = true;
                modull.preloaded = true;
            }
function (initialClass, mockClass) {
                if (this._overriddenClasses == null) {
                    this._overriddenClasses = {};
                }
                var cacheKey = Aria.getLogicalPath(initialClass, ".js", true);
                var clsInfos = this._overriddenClasses[initialClass];
                if (clsInfos == null) { // only save the previous class if it was not already overridden
                    var currentClass = Aria.nspace(initialClass);
                    if (currentClass == null) {
                        return; // invalid namespace
                    }
                    var idx = initialClass.lastIndexOf('.');
                    if (idx > -1) {
                        clsInfos = {
                            clsNs : initialClass.slice(0, idx),
                            clsName : initialClass.slice(idx + 1),
                            initialClass : currentClass
                        };
                    } else {
                        clsInfos = {
                            clsNs : '',
                            clsName : initialClass,
                            initialClass : currentClass
                        };
                    }
                    clsInfos.cachedModule = require.cache[cacheKey];
                    this._overriddenClasses[initialClass] = clsInfos;
                }

                // alter the global classpath to point to the mock
                var ns = Aria.nspace(clsInfos.clsNs);
                ns[clsInfos.clsName] = mockClass;

                // also alter require cache
                delete require.cache[cacheKey];
                var currentContext = require("noder-js/currentContext");
                var modull;
                if (currentContext) {
                    modull = currentContext.getModule(cacheKey);
                } else {
                    modull = {
                        id : cacheKey,
                        filename : cacheKey
                    };
                    require.cache[cacheKey] = modull;
                }
                modull.exports = mockClass;
                modull.loaded = true;
                modull.preloaded = true;
            }
function ( initialClass , mockClass ) { if ( this . _overriddenClasses == null ) { this . _overriddenClasses = { } ; } var cacheKey = Aria . getLogicalPath ( initialClass , ".js" , true ) ; var clsInfos = this . _overriddenClasses [ initialClass ] ; if ( clsInfos == null ) { // only save the previous class if it was not already overridden var currentClass = Aria . nspace ( initialClass ) ; if ( currentClass == null ) { return ; // invalid namespace } var idx = initialClass . lastIndexOf ( '.' ) ; if ( idx > - 1 ) { clsInfos = { clsNs : initialClass . slice ( 0 , idx ) , clsName : initialClass . slice ( idx + 1 ) , initialClass : currentClass } ; } else { clsInfos = { clsNs : '' , clsName : initialClass , initialClass : currentClass } ; } clsInfos . cachedModule = require . cache [ cacheKey ] ; this . _overriddenClasses [ initialClass ] = clsInfos ; } // alter the global classpath to point to the mock var ns = Aria . nspace ( clsInfos . clsNs ) ; ns [ clsInfos . clsName ] = mockClass ; // also alter require cache delete require . cache [ cacheKey ] ; var currentContext = require ( "noder-js/currentContext" ) ; var modull ; if ( currentContext ) { modull = currentContext . getModule ( cacheKey ) ; } else { modull = { id : cacheKey , filename : cacheKey } ; require . cache [ cacheKey ] = modull ; } modull . exports = mockClass ; modull . loaded = true ; modull . preloaded = true ; }
Overrides a class with another.
@param {String} Classpath of the class to be overridden (e.g. 'aria.core.DownloadMgr')
@param {Object} Overriding class (e.g. test.aria.core.DownloadMgrMock) If the class was already
overridden, the current class with namespace initialClass is not saved. It is not specific to classes
which use the Aria.classDefinition mechanism (does not use $class and $package)
Overrides a class with another .