104104 );
105105 }
106106
107- setTestboxEnvironment ()
107+ // Sets up the test environment
108+ local .testRunner = new tests .TestRunner ();
109+ local .testRunner .setTestboxEnvironment ()
108110
109111 if (! structKeyExists (url , " format" ) || url .format eq " html" ) {
110112 // Determine reporter for HTML format
256258 type = " App" ;
257259 include " /wheels/tests_testbox/html.cfm" ;
258260 }
259-
260- private function setTestboxEnvironment () {
261- // creating backup for original environment
262- if (structKeyExists (server , " boxlang" )) {
263- application .$$$wheels = $duplicateWheelsEnvironment (application .wheels )
264- } else {
265- application .$$$wheels = Duplicate (application .wheels )
266- }
267-
268- // load testbox routes
269- application .wo .$include (template = " /tests/routes.cfm" )
270- application .wo .$setNamedRoutePositions ()
271-
272- local .AssetPath = " /tests/_assets/"
273-
274- application .wo .set (rewriteFile = " index.cfm" )
275- application .wo .set (controllerPath = local .AssetPath & " controllers" )
276- application .wo .set (viewPath = local .AssetPath & " views" )
277- application .wo .set (modelPath = local .AssetPath & " models" )
278- application .wo .set (wheelsComponentPath = " /wheels" )
279-
280- /* turn off default validations for testing */
281- application .wheels .automaticValidations = false
282- application .wheels .assetQueryString = false
283- application .wheels .assetPaths = false
284-
285- /* redirections should always delay when testing */
286- application .wheels .functions .redirectTo .delay = true
287-
288- /* enable transactions for proper test isolation */
289- application .wheels .transactionMode = " commit"
290-
291- /* turn off request query caching */
292- application .wheels .cacheQueriesDuringRequest = false
293-
294- // CSRF
295- application .wheels .csrfCookieName = " _wheels_test_authenticity"
296- application .wheels .csrfCookieEncryptionAlgorithm = " AES"
297- application .wheels .csrfCookieEncryptionSecretKey = GenerateSecretKey (" AES" )
298- application .wheels .csrfCookieEncryptionEncoding = " Base64"
299-
300- // Setup CSRF token and cookie. The cookie can always be in place, even when the session-based CSRF storage is being
301- // tested.
302- dummyController = application .wo .controller (" dummy" )
303- csrfToken = dummyController .$generateCookieAuthenticityToken ()
304-
305- cookie [application .wheels .csrfCookieName ] = Encrypt (
306- SerializeJSON ({authenticityToken = csrfToken }),
307- application .wheels .csrfCookieEncryptionSecretKey ,
308- application .wheels .csrfCookieEncryptionAlgorithm ,
309- application .wheels .csrfCookieEncryptionEncoding
310- )
311- if (structKeyExists (url , " db" ) && listFind (" mysql,sqlserver,postgres,h2" , url .db )){
312- application .wheels .dataSourceName = " wheelstestdb_" & url .db ;
313- } else if (application .wheels .coreTestDataSourceName eq " |datasourceName|" ) {
314- application .wheels .dataSourceName = " wheelstestdb" ;
315- } else {
316- application .wheels .dataSourceName = application .wheels .coreTestDataSourceName ;
317- }
318- application .testenv .db = application .wo .$dbinfo (datasource = application .wheels .dataSourceName , type = " version" )
319-
320- local .populate = StructKeyExists (url , " populate" ) ? url .populate : true
321- if (local .populate ) {
322- include " /tests/populate.cfm"
323- }
324- }
325-
326- private function $duplicateWheelsEnvironment(required struct original ) {
327- local .backup = {}
328- for (local .key in arguments .original ) {
329- if (IsSimpleValue (arguments .original [local .key ]) || IsArray (arguments .original [local .key ]) || IsStruct (arguments .original [local .key ])) {
330- local .backup [local .key ] = arguments .original [local .key ]
331- }
332- }
333- return local .backup
334- }
335261 </cfscript >
0 commit comments