joii-unit
Version:
UnitTest Framework for JOII-based applications
2 lines • 29.9 kB
JavaScript
/*! joii-unit 0.1.0 2014-12-06 */
!function(a,b,c){a.JOII.Unit=b({"private object config":{parameters:{environment:c,loader:c,reporter:c,dependencies:[],tests:[],verbose:!0},services:{"joii.unit.reporter":{"class":c,arguments:["%environment%","%verbose%"]},"joii.unit.loader":{"class":c,arguments:["%dependencies%","%tests%","@joii.unit.reporter"]},"joii.unit.annotation_reader":{"class":"JOII.Unit.AnnotationReader.AnnotationReader",arguments:["@joii.unit.reporter","@joii.unit.loader"]},"joii.unit.test_manager":{"class":"JOII.Unit.TestCaseManager",arguments:["@joii.unit.annotation_reader","@joii.unit.reporter","@joii.unit.loader"]}}},"public immutable object container":null,"private __construct":function(a,b){if("undefined"!=typeof JOII.Unit.instance)throw"Another instance of JOII.Unit is already active!";JOII.Unit.instance=this.__api__,a=a=a||{},b=b=b||{};var d=JOII.Compat.extend,e=this.config;this.config.parameters=d(!0,e.parameters,a),this.config.services=d(!0,e.services,b),this.config.parameters.environment=this.determineEnvironemnt();var f=this.config.parameters.reporter;f===c?(d=this.config.parameters.environment,d=d.charAt(0).toUpperCase()+d.slice(1)+"Reporter",this.config.services["joii.unit.reporter"]["class"]="JOII.Unit.Reporter."+d):this.config.services["joii.unit.reporter"]["class"]=f;var g=this.config.parameters.loader;g===c?(d=this.config.parameters.environment,d=d.charAt(0).toUpperCase()+d.slice(1)+"Loader",this.config.services["joii.unit.loader"]["class"]="JOII.Unit.Loader."+d):this.config.services["joii.unit.loader"]["class"]=g;var h=new JOII.Unit.DependencyInjection.ServiceContainer;h.loadConfiguration(this.config),this.container=h.getContainer();var i=this.container.get("joii.unit.reporter");if(!JOII.isInstance(i)||!i.instanceOf(JOII.Unit.ReporterInterface))throw new Error("Reporter is not an instance of JOII.Unit.ReporterInterface");i.init();var j=this.container.get("joii.unit.loader");j.load(JOII.Compat.Bind(this.runTests,this))},"private function runTests":function(){var a,b,c,d,e=this.container.get("joii.unit.test_manager").getTests(),f={testcases:[],assertions:{passed:0,failed:0,total:0},testcount:0,runtime:0};for(var g in e)b=e[g].getTestCase(),a=e[g].run(),c=b.filename,d=b.reflector.getName(),"undefined"==typeof f.testcases[c]&&(f.testcases[c]={}),f.testcases[c][d]=a,f.assertions.passed+=a.assertions.passed,f.assertions.failed+=a.assertions.failed,f.assertions.total+=a.assertions.passed+a.assertions.failed,f.testcount++;this.container.get("joii.unit.reporter").reportSummary(f)},"private function determineEnvironemnt":function(){if("undefined"!=typeof window)return"browser";if("undefined"!=typeof global&&module&&require)return"node";throw new Error("JOII-Unit is unable to determine the current environment.")}}),a.JOII.Unit.Namespace=function(b){var c=a.JOII.Unit;if(""!==b)for(var d=b.split("."),e=0;e<d.length;e++)c[d[e]]||(c[d[e]]={}),c=c[d[e]];return c}}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("");d.AbstractAnnotation=c({"abstract":!0},{"final public immutable name":null,"final protected immutable definition":null,"final protected immutable method":null,"final protected immutable data":null,"final private __construct":function(a,b,c,d){this.definition=a,this.method=b,this.name=c,this.data=d},"final public function toString":function(){return"[Annotation "+this.getName()+": "+this.getData()+"]"},"abstract public function accepts":function(){}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){b("").LoaderInterface=c("JOII.Unit.Loader",{"private function __construct":function(){},"public function load":function(){},"public function getLastLoadedFile":function(){},"public function getSource":function(){}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.InterfaceBuilder),function(a,b,c){b("").ReporterInterface=c("JOII.Unit.Reporter",{"private __construct":function(){},"public function init":function(){},"public function reportAssertPass":function(){},"public function reportAssertFail":function(){},"public function critical":function(){},"public function error":function(){},"public function debug":function(){}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.InterfaceBuilder),function(a,b,c){var d=b("");d.TestCaseManager=c({"private annotation_reader":null,"private reporter":null,"private loader":null,"private tests":[],"private __construct":function(a,b,c){this.annotation_reader=a,this.reporter=b,this.loader=c},"public function addTest":function(a){a.reflector=new JOII.Reflection.Class(a),a.filename=this.loader.getLastLoadedFile(),a.annotations=this.annotation_reader.get(a);var b=[],c=a.reflector.getMethods();for(var d in c)c[d].isPublic()&&"test"===c[d].getName().substr(0,4)&&b.push(c[d].getName());a.methods=b,this.tests.push(new JOII.Unit.TestCase.Process(a,this.reporter)),this.reporter.debug('TestCaseManager::addTest - TestCase: "'+a.reflector.getName()+'" (from: '+a.filename+"), "+b.length+" test(s).")},"public function getTests":function(){return this.tests}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("AnnotationReader");d.AnnotationMethod=c({"private string method":null,"private object annotations":null,"private __construct":function(a,b){this.annotations=b||[],this.method=a},"public function get":function(a){for(var b in this.annotations)if(this.annotations[b].instanceOf(a)||this.annotations[b].getName()===a)return this.annotations[b];throw new Error('Annotation "'+a+'" not found on method "'+this.method+'"')},"public function has":function(a){try{return this.get(a),!0}catch(b){return!1}}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("AnnotationReader");d.AnnotationParser=c({"private number pointer":0,"private string source":"","public annotations":{},"private __construct":function(a,b){this.source=this.trim(a.replace(/\'/g,'"').replace(/\"+/g,'"')),b='"'+b.substr(0,b.length-4);var c=this.seek(b),d=this.seek("JOII.Unit.TestCase");d=d===!1?this.source.length:d,this.source=this.source.substring(c,d),this.pointer=0;for(var e,f,g;!1!==this.seek("/*");){e=this.pointer,f=this.seek("*/"),g=this.seek(":");var h=this.parseDocblock(this.source.substring(e,f)),i=this.parseDeclaration(this.source.substring(f+2,g));this.annotations[i]=h}},"private function parseDeclaration":function(a){a=a.replace(/\"/g,""),a=this.trim(a.replace(/\n/g,"").replace(/\r/g,"").replace(/\s+/g," "));var b=a.split(" ");return b[b.length-1]},"private function parseDocblock":function(a){var b,c,d=[],e=0,f=!1;for(a=this.trim(a.replace(/\n/g,"").replace(/\r/g,"").replace(/\s+/g," ")),b=0;b<a.length;b++)c=a.charAt(b),'"'===c&&f===!1?f=!0:'"'===c&&f===!0&&(f=!1),(f!==!1||"*"!==c)&&("@"!==c?("undefined"==typeof d[e]&&(d[e]=""),d[e]+=c):f===!1&&"@"===c&&(d[e]=this.trim(d[e]),e++));return d.shift(),d},"private function seek":function(a){for(var b=this.pointer-1;b<this.source.length;b++){for(var c=0,d=0;d<a.length;d++){if(b+d>this.source.length)return!1;if(a.charAt(d)!==this.source.charAt(b+d))break;c++}if(c===a.length)return this.pointer=b,this.pointer}return!1},"private trim":function(a){a=a.replace(/^\s+/,"");for(var b=a.length-1;b>=0;b--)if(/\S/.test(a.charAt(b))){a=a.substring(0,b+1);break}return a}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("AnnotationReader");d.AnnotationReader=c({"private object cache":{},"private JOII.Unit.Reporter reporter":null,"private JOII.Unit.Loader loader":null,"private __construct":function(a,b){this.reporter=a,this.loader=b},"public function get":function(a){var b=a.filename,c=a.reflector.getName(),d=b+":"+c;if("undefined"!=typeof this.cache[d])return this.cache[d];var e=JOII.Unit.AnnotationReader.AnnotationParser,f=JOII.Unit.AnnotationReader.Annotations,g=new e(this.loader.getSource(b),c);return this.reporter.debug("AnnotationReader::get - Parsing annotations for "+b+", scope: "+c),this.cache[d]=new f(this.hydrateAnnotations(a,g)),this.cache[d]},"private hydrateAnnotations":function(a,b){var c,d=b.getAnnotations(),e={};for(c in d){e[c]=[];for(i in d[c])e[c].push(this.parseAnnotation(a,c,d[c][i]))}return e},"private parseAnnotation":function(a,b,c){var d=c.split(" "),e=d[0],c="";d.shift(),c=d.join(" ");for(var f in JOII.Unit.Annotation)if("function"==typeof JOII.Unit.Annotation[f]){var g=new JOII.Unit.Annotation[f](a,b,e,c);if("function"==typeof g.accepts&&g.accepts(e))return g.init(),g;delete g}throw new Error('Unknown Annotation: "'+e+'"')}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("AnnotationReader");d.Annotations=c({"private object annotations":null,"private object cache":{},"private __construct":function(a){this.annotations=a},"public function getMethod":function(a){if("undefined"==typeof this.cache[a]){var b=JOII.Unit.AnnotationReader.AnnotationMethod,c=this.annotations[a];this.cache[a]=new b(a,c)}return this.cache[a]}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("Annotation.Behavior");d.ExceptionBehavior=c("UAB_Exception",{"public function isValid":function(){},"public function getExceptionString":function(){},"public function getExpectedExceptionString":function(){}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.InterfaceBuilder),function(a,b,c){var d=b("Annotation.Behavior");d.TestExecutorBehavior=c("UAB_TestExecutor",{"public function execute":function(){}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.InterfaceBuilder),function(a,b,c,d){var e=b("Annotation");e.DataProvider=c("JOII.Unit.Annotation.DataProvider",{"extends":JOII.Unit.AbstractAnnotation,"implements":["UAB_TestExecutor"]},{"private string provider":null,"public function accepts":function(a){return"dataprovider"===a.toLowerCase()},"public function init":function(){if(this.provider=JSON.parse(this.getData()),!this.getDefinition().reflector.hasMethod(this.provider))throw new Error("DataProvider '"+this.provider+"' for method '"+this.getMethod()+"' in TestCase '"+this.getDefinition().reflector.getName()+"' does not exist.")},"public function execute":function(a){var b=new this.definition,c=b[this.provider]();for(var e in c)a.apply(d,c[e])}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("Annotation");d.ExpectedException=c("JOII.Unit.Annotation.ExpectedException",{"extends":JOII.Unit.AbstractAnnotation,"implements":["UAB_Exception"]},{"public function accepts":function(a){return"expectedexception"===a.toLowerCase()},"public function init":function(){JSON.parse(this.getData())},"public function isValid":function(a){return this.getExceptionString(a)===this.getExpectedExceptionString()},"public function getExceptionString":function(a){return"object"==typeof a?a.message:a},"public function getExpectedExceptionString":function(){return JSON.parse(this.getData())}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("Loader");d.NodeLoader=c({"implements":JOII.Unit.LoaderInterface},{"protected object files":[],"protected object source":{},"protected object reporter":null,"protected string last_file":"","private __construct":function(a,b,c){var d,e=[];for(d in a)e.push(a[d]);for(d in b)e.push(b[d]);this.setFiles(e),this.setReporter(c)},"public function load":function(a){if(0===this.files.length)return void this.reporter.critical("No test files registered.");var b,c,d=[],e=require("fs");for(c in this.files)b=this.absPath(this.files[c]),this.last_file=this.files[c],this.reporter.debug("NodeLoader::load - Loading file "+this.files[c]+" ("+b+")"),this.source[this.files[c]]=e.readFileSync(b,"utf8"),require(b),d.push(this.files[c]);a(d)},"public function getLastLoadedFile":function(){return this.last_file},"private function absPath":function(a){return"/"!=a.charAt(0)&&(a=require("path").resolve(process.cwd(),a)),a},"public getSource":function(a){if("undefined"==typeof this.source[a])throw new Error('Source code for file "'+a+'" is unavailable.');return this.source[a]}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("Reporter");d.NodeReporter=c({"implements":JOII.Unit.ReporterInterface},{"private boolean verbose":!1,"private object output":null,"private object color":null,"private number lc":0,"private number ac":0,"private __construct":function(a,b){if("node"!==a)throw new Error("NodeReporter requires a NodeJS environment!");this.verbose=b,this.output=process.stdout,this.color=require("cli-color")},"public function init":function(){var a,b;try{var c=JSON.parse(require("fs").readFileSync(__dirname+"/../package.json","utf8"));a=this.color.cyan.bold(c.name)+this.color.cyan(" (module) ")+this.color.cyan.bold(c.version)+", by "+c.author+"\n",b=c.homepage+"\n\n"}catch(d){a=this.color.cyan.bold("joii-unit")+this.color.cyan(" (standalone)")+", by Harold Iedema\n",b="https://github.com/haroldiedema/joii-unit/\n\n"}process.stdout.write("\n"+a+b)},"public function reportAssertPass":function(){this.output.write("."),this.lc++,this.ac++,this.lc>70&&(this.output.write(" ("+this.ac+")\n"),this.lc=0)},"public function reportAssertFail":function(){this.output.write(this.color.bgRed.white.bold("F")),this.lc++,this.ac++,this.lc>70&&(this.output.write(" ("+this.ac+")\n"),this.lc=0)},"public function reportSummary":function(a){this.output.write("\n\n"),a.assertions.failed>0?(this.output.write(this.color.bgRed.white.bold("FAILURES! Tests: "+a.testcount+", Assertions: "+a.assertions.total+", Failures: "+a.assertions.failed)+"\n\n"),this.reportSummaryFailed(a)):this.output.write(this.color.bgGreen.black("OK ("+a.testcount+" tests, "+a.assertions.total+" assertions)")+"\n\n")},"private function reportSummaryFailed":function(a){var b,c,d,e,f,g,h;for(b in a.testcases)for(c in a.testcases[b]){d=a.testcases[b][c].tests;for(e in d)for(f in d[e])if(d[e][f].passed===!1){g=d[e][f],h=g.trace.split("\n"),this.output.write(b+" ("+c+")\n"),this.output.write(' Assertion : "'+g.message+'"\n'),this.output.write(" Expected : "+JSON.stringify(g.expected)+"\n"),this.output.write(" Actual : "+JSON.stringify(g.actual)+"\n");for(var i in h)h[i]=h[i].replace(/\\/g,"/"),-1!==h[i].indexOf(b)&&-1!==h[i].indexOf(c)&&this.output.write(this.color.blackBright(h[i])+"\n");this.output.write("\n")}}},"public function critical":function(a){process.stdout.write("\n"+this.color.bgRed.white.bold("CRITICAL: "+a)+"\n\n")},"public function error":function(a){process.stdout.write("\n"+this.color.bgRed.white.bold("ERROR: "+a)+"\n\n")},"public function debug":function(a){this.verbose&&process.stdout.write(this.color.blackBright(a)+"\n")}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("DependencyInjection");d.Container=c({"private object definitions":{},"private object parameters":{},"private object loading":{},"private object passes":[],"private boolean is_frozen":!1,"private boolean is_compiling":!1,"private __construct":function(){return this.api},"public function register":function(a,b){if(this.is_frozen)throw new Error("Unable to register a new Definition on a frozen container.");return this.definitions[a]=new d.Definition(b),this.definitions[a]},"public function addCompilerPass":function(a){if("function"==typeof a&&(a=new a),"function"!=typeof a.compile)throw new Error("The CompilerPass doesn't have a compile function.");this.passes.push(a)},"public function compile":function(){if(this.is_compiling)throw new Error("The container is already compiling.");if(this.is_compiling=!0,this.is_frozen)throw new Error("Unable to compile a container which is already compiled.");for(var a in this.passes)this.passes[a].compile(this);this.is_compiling=!1,this.is_frozen=!0},"public function isFrozen":function(){return this.is_frozen},"public function get":function(a){if(this.is_frozen||this.compile(),"undefined"==typeof this.definitions[a])throw new Error("Service "+a+" does not exist.");var b=this.definitions[a];if(b.hasInstance())return b.getInstance();if(this.loading[a]===!0)throw new Error("Service "+a+" has a circular reference to itself.");this.loading[a]=!0;var c=this.createService(b);return delete this.loading[a],c},"public function createService":function(a){if(a.hasInstance())throw new Error("Attempt to create a service that already has an instance.");var b=this.getParameterArray(a.getArguments()),c=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},d=a.getFunction(),e=c(d,b);a.setInstance(e);var f=a.getMethodCalls();for(var g in f)if(f.hasOwnProperty(g)){var h=f[g][0],i=this.getParameterArray(f[g][1]||[]);if("function"!=typeof e[h])throw new Error("Method "+h+" does not exist.");e[h].apply(e,i)}return e},"public function getServiceIds":function(){var a=[];for(var b in this.definitions)this.definitions.hasOwnProperty(b)&&a.push(b);return a},"public function setDefinitions":function(a){if(this.is_frozen)throw new Error("Unable to register a new Definition on a frozen container.");return this.definitions={},this.addDefinitions(a),this.api},"public function addDefinitions":function(a){for(var b in a)if(a.hasOwnProperty(b)){var c=a[b];this.setDefinition(b,c)}return this.api},"public function setDefinition":function(a,b){if(this.is_frozen)throw new Error("Unable to register a new Definition on a frozen container.");return this.definitions[a]=b,this.api},"public function hasDefinition":function(a){return"undefined"!=typeof this.definitions[a]},"public function getDefinition":function(a){if("undefined"==typeof this.definitions[a])throw new Error("The service definition "+a+" does not exist.");return this.definitions[a]},"public function findTaggedServiceIds":function(a){var b={};for(var c in this.definitions)this.definitions.hasOwnProperty(c)&&this.definitions[c].hasTag(a)&&(b[c]=this.definitions[c].getTag(a));return b},"public function setParameters":function(a){if(this.is_frozen)throw new Error("Unable to update parameters on a frozen container.");return this.parameters=a,this.api},"public function setParameter":function(a,b){if(this.is_frozen)throw new Error("Unable to update parameters on a frozen container.");return this.parameters[a]=b,this.api},"public function hasParameter":function(a){return"undefined"!=typeof this.parameters[a]},"public function getParameter":function(a){if("undefined"!=typeof this.parameters[a])return this.parameters[a];throw new Error("Parameter "+a+" does not exist.")},"private function getParameterArray":function(a){var b=[];for(var c in a){var d=a[c];"string"==typeof d&&(d=this.resolveParameter(d)),b.push(d)}return b},"private function resolveParameter":function(a){return"string"!=typeof a?a:"@"===a.charAt(0)?this.get(a.slice(1,a.length)):"%"===a.charAt(0)&&"%"===a.charAt(a.length-1)?this.getParameter(a.slice(1,a.length-1)):a}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("DependencyInjection");d.Definition=c({"private object name":null,"private object fn":null,"private object instance":null,"private object api":null,"private object is_public":!0,"private object args":[],"private object calls":[],"private object tags":{},"private __construct":function(a){this.fn="function"!=typeof a?this.findFunctionFromString(a):a},"public function addArgument":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.args.push(a),this},"public function setArguments":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.args=a,this},"public function getArguments":function(){return this.args},"public function setMethodCalls":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");this.calls=[];for(var b in a)a.hasOwnProperty(b)&&(this.calls[b]=a[b]);return this},"public function addMethodCall":function(a,b){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return b=b||[],this.calls.push([a,b]),this},"public function removeMethodCall":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");for(var b in this.calls)this.calls[b][0]===a&&delete this.calls[b];return this},"public function hasMethodCall":function(a){for(var b in this.calls)if(this.calls[b][0]===a)return!0;return!1},"public function getMethodCalls":function(){return this.calls},"public function setTags":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.tags=a,this},"public function getTags":function(){return this.tags},"public function getTag":function(a){return"undefined"!=typeof this.tags[a]?this.tags[a]:[]},"public function addTag":function(a,b){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return"undefined"==typeof this.tags[a]&&(this.tags[a]=[]),this.tags[a].push(b),this},"public function hasTag":function(a){return"undefined"!=typeof this.tags[a]},"public function clearTag":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return"undefined"!=typeof this.tags[a]&&delete this.tags[a],this},"public function clearTags":function(){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.tags={},this},"public function setPublic":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.is_public=a,this},"public function isPublic":function(){return this.is_public},"public function hasInstance":function(){return!!this.instance},"public function getInstance":function(){if("undefined"!=typeof this.instance)return this.instance;throw new Error("Definition is not initialized.")},"public function setInstance":function(a){if(this.hasInstance())throw new Error("Unable to update a definition that is already initialized.");return this.instance=a,this},"public function getFunction":function(){return this.fn},"private function findFunctionFromString":function(b){if(-1===b.indexOf(".")){if("function"==typeof a[b])return a[b];throw new Error(b+" is undefined or not a function.")}for(var c,d=b.split("."),e=a,f="";c=d.shift();){if(f+=c,"undefined"==typeof e[c]||"object"!=typeof e[c]&&"function"!=typeof e[c])throw new Error(f+" is undefined or not iterable.");e=e[c],f+="."}return e}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c){var d=b("DependencyInjection");d.ServiceContainer=c({"private object container":null,"private __construct":function(a){"undefined"!=typeof a&&a||(a=new d.Container),this.container=a},"public function getContainer":function(){return this.container},"public function loadConfiguration":function(a){if("object"!=typeof a)throw new Error("loadConfiguration expectes an object, "+typeof a+" given.");if("undefined"==typeof a.parameters&&"undefined"==typeof a.services)throw new Error("The configuration object must have a 'parameters' and/or 'services' element.");if("object"==typeof a.parameters&&this.loadParameters(a.parameters),"object"==typeof a.services)for(var b in a.services)a.services.hasOwnProperty(b)&&this.loadService(b,a.services[b])},"private function loadParameters":function(a){for(var b in a)a.hasOwnProperty(b)&&this.container.setParameter(b,a[b])},"private function loadService":function(a,b){var c=this.container.register(a,b["class"]);"undefined"!=typeof b.arguments&&c.setArguments(b.arguments),"undefined"!=typeof b.calls&&c.setMethodCalls(b.calls),"undefined"!=typeof b.tags&&c.setTags(b.tags)}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c,d){var e=b("");e.TestCase=c({__call:function(){e.TestCase.Register.apply(d,arguments)},"final public object on_pass":null,"final public object on_fail":null,"final private __construct":function(a,b){this.on_pass=a||function(){},this.on_fail=b||function(a,b,c){throw new Error(a+"\n Expected : "+JSON.stringify(c)+"\n Actual : "+JSON.stringify(b)+"\n")}},"final private function pass":function(a,b,c){try{throw new Error(a)}catch(d){trace=d.stack}this.on_pass(a,b,c,trace)},"final private function fail":function(a,b,c){var d=[];try{throw new Error(a)}catch(e){d=e.stack}this.on_fail(a,b,c,d)}}),e.TestCase.Register=function(a,b){var d=JOII.Unit.instance;if("undefined"==typeof d)throw new Error("Unable to register a TestCase without an active JOII.Unit instance.");"Test"!==a.substr(a.length-4)&&(a+="Test");var e,f=[];for(e in JOII.Unit.TestCase.Traits)f.push(JOII.Unit.TestCase.Traits[e]);var g=c(a,{"extends":JOII.Unit.TestCase,uses:f},b);d.getContainer().get("joii.unit.test_manager").addTest(g)}}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b,c,d){var e=b("TestCase");e.Process=c({"private testcase":null,"private reporter":null,"private current_test":null,"private result":{},"private __construct":function(a,b){this.testcase=a,this.reporter=b,this.result.testcase=a,this.result.tests={},this.result.assertions={passed:0,failed:0},this.result.runtime=0},"public function getTestCase":function(){return this.testcase},"public function run":function(){for(var a in this.testcase.methods){var b=this.testcase.methods[a],c=this.testcase.annotations.getMethod(b);if(this.current_method=b,this.result.tests[b]=[],c.has("UAB_TestExecutor")){var e=c.get("UAB_TestExecutor");this.dataset=0,e.execute(JOII.Compat.Bind(function(){this.dataset++,this.runTest(b,arguments)},this))}else this.dataset=d,this.runTest(this.testcase.methods[a],[])}return this.result},"private function runTest":function(a,b){var c=JOII.Compat.Bind(this.registerPass,this),e=JOII.Compat.Bind(this.registerFail,this),f=new this.testcase(c,e),g=this.testcase.annotations.getMethod(a);if(this.testcase.reflector.hasMethod("setup")&&f.setup(),this.current_test=a,g.has("UAB_Exception")){var h=g.get("UAB_Exception").getExpectedExceptionString();try{f[a].apply(d,b),e('The expected exception "'+h+'" was never thrown.',d,h)}catch(i){if(g.get("UAB_Exception").isValid(i))var j="The expected exception was thrown.",k=c;else var j="Thrown exception did not match the expected exception.",k=e;i=g.get("UAB_Exception").getExceptionString(i),k(j,i,h)}}else f[a].apply(d,b);this.testcase.reflector.hasMethod("teardown")&&f.teardown()},"private function registerPass":function(a,b,c,e){this.dataset!==d&&(a="[dataset #"+this.dataset+"] "+a),this.result.assertions.passed++,this.result.tests[this.current_method].push({passed:!0,message:a,actual:b,expected:c,trace:e}),this.reporter.reportAssertPass(this.testcase,this.current_test,a,b,c,e)},"private function registerFail":function(a,b,c){this.dataset!==d&&(a="[dataset #"+this.dataset+"] "+a),this.result.assertions.failed++,this.result.tests[this.current_method].push({passed:!1,message:a,actual:b,expected:c,trace:trace}),this.reporter.reportAssertFail(this.testcase,this.current_test,a,b,c,trace)}})}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder),function(a,b){var c=b("TestCase.Traits");c.AssertScalar={"final protected assert":function(a,b,c,d){this[a===!0?"pass":"fail"](b,c,d)},"final protected function assertTrue":function(a,b){this.assert(a===!0,b,a,!0)},"final protected function assertFalse":function(a,b){this.assert(a===!1,b,a,!1)},"final protected function assertEqual":function(a,b,c){this.assert(a==b,c,a,b)},"final protected function assertNotEqual":function(a,b,c){this.assert(a!=b,c,a,b)},"final protected function assertEqualStrict":function(a,b,c){this.assert(a===b,c,a,b)},"final protected function assertNotEqualStrict":function(a,b,c){this.assert(a!==b,c,a,b)}}}("undefined"!=typeof window?window:global,("undefined"!=typeof window?window:global).JOII.Unit.Namespace,("undefined"!=typeof window?window:global).JOII.ClassBuilder);