Show
Ignore:
Timestamp:
05/21/09 00:53:49 (4 years ago)
Author:
lmajano
Message:

mock box updates

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/system/testing/BaseTestCase.cfc

    r2257 r2280  
    2424           of the Application Start Handler to be executed. 
    2525 
     26<cfscript> 
     27people = querySim(' 
     28id , name , mail 
     291 | weed | weed@theflowerpot.not 
     302 | bill | bill@theflowerpot.not 
     313 | ben | ben@theflowerpot.not 
     32'); 
     33</cfscript> 
     34 
    2635----------------------------------------------------------------------> 
    2736<cfcomponent name="BaseTestCase"  
    2837                         extends="mxunit.framework.TestCase"  
    2938                         output="false"  
    30                          hint="A base unit test case for MXUnit"> 
     39                         hint="A base unit test case for doing ColdBox Testing"> 
    3140 
    3241<!------------------------------------------- CONSTRUCTOR -------------------------------------------> 
     
    3948                instance.configMapping = ""; 
    4049                instance.controller = 0; 
     50                instance.coldboxAppKey = "cbController"; 
    4151                 
    4252                /* Public Properties */ 
     
    5969                if( this.loadColdbox ){ 
    6070                        /* Check on Scope Firsty */ 
    61                         if( structKeyExists(application,"cbController") ){ 
    62                                 instance.controller = application.cbController; 
     71                        if( structKeyExists(application,getColdboxAppKey()) ){ 
     72                                instance.controller = application[getColdboxAppKey()]; 
    6373                        } 
    6474                        else{ 
     
    6777                                /* Verify Persistence */ 
    6878                                if( this.persist_framework ){ 
    69                                         application.cbController = instance.controller; 
     79                                        application[getColdboxAppKey()] = instance.controller; 
    7080                                } 
    7181                                /* Setup */ 
     
    99109                <cfset structDelete(application,"cbController")> 
    100110        </cffunction> 
    101  
     111         
     112        <!--- get/Set Coldbox App Key ---> 
     113        <cffunction name="getcoldboxAppKey" access="public" output="false" returntype="string" hint="Get the coldboxAppKey"> 
     114                <cfreturn instance.coldboxAppKey/> 
     115        </cffunction> 
     116        <cffunction name="setcoldboxAppKey" access="public" output="false" returntype="void" hint="Override the coldboxAppKey"> 
     117                <cfargument name="coldboxAppKey" type="string" required="true"/> 
     118                <cfset instance.coldboxAppKey = arguments.coldboxAppKey/> 
     119        </cffunction> 
     120         
    102121        <!--- getter for AppMapping ---> 
    103122        <cffunction name="getAppMapping" access="private" returntype="string" output="false" hint="Get the AppMapping"> 
     
    210229                <cfabort> 
    211230        </cffunction> 
     231         
     232        <cfscript> 
     233        /** 
     234        * Accepts a specifically formatted chunk of text, and returns it as a query object. 
     235        * v2 rewrite by Jamie Jackson 
     236        * 
     237        * @param queryData      Specifically format chunk of text to convert to a query. (Required) 
     238        * @return Returns a query object. 
     239        * @author Bert Dawson (bert@redbanner.com) 
     240        * @version 2, December 18, 2007 
     241        *  
     242        */ 
     243        function querySim(queryData) { 
     244            var fieldsDelimiter="|"; 
     245            var colnamesDelimiter=","; 
     246            var listOfColumns=""; 
     247            var tmpQuery=""; 
     248            var numLines=""; 
     249            var cellValue=""; 
     250            var cellValues=""; 
     251            var colName=""; 
     252            var lineDelimiter=chr(10) & chr(13); 
     253            var lineNum=0; 
     254            var colPosition=0; 
     255         
     256            // the first line is the column list, eg "column1,column2,column3" 
     257            listOfColumns = Trim(ListGetAt(queryData, 1, lineDelimiter)); 
     258             
     259            // create a temporary Query 
     260            tmpQuery = QueryNew(listOfColumns); 
     261         
     262            // the number of lines in the queryData 
     263            numLines = ListLen(queryData, lineDelimiter); 
     264             
     265            // loop though the queryData starting at the second line 
     266            for(lineNum=2; lineNum LTE numLines; lineNum = lineNum + 1) { 
     267             cellValues = ListGetAt(queryData, lineNum, lineDelimiter); 
     268         
     269                if (ListLen(cellValues, fieldsDelimiter) IS ListLen(listOfColumns,",")) { 
     270                    QueryAddRow(tmpQuery); 
     271                    for (colPosition=1; colPosition LTE ListLen(listOfColumns); colPosition = colPosition + 1){ 
     272                        cellValue = Trim(ListGetAt(cellValues, colPosition, fieldsDelimiter)); 
     273                        colName = Trim(ListGetAt(listOfColumns,colPosition)); 
     274                        QuerySetCell(tmpQuery, colName, cellValue); 
     275                    } 
     276                } 
     277            } 
     278             
     279            return( tmpQuery ); 
     280             
     281        } 
     282        </cfscript> 
    212283 
    213284</cfcomponent>