-
-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathMockFlash.cfc
executable file
·62 lines (53 loc) · 1.36 KB
/
MockFlash.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
* A flash scope that is used for unit testing.
*
* @author Luis Majano <lmajano@ortussolutions.com>
*/
component extends="coldbox.system.web.flash.AbstractFlashScope" accessors="true" {
// The flash struct
property name="mockFlash";
/**
* Constructor
*
* @controller.hint ColdBox Controller
* @defaults.hint Default flash data packet for the flash RAM object=[scope,properties,inflateToRC,inflateToPRC,autoPurge,autoSave]
*/
function init( required controller, required struct defaults = {} ){
super.init( argumentCollection = arguments );
variables.mockFlash = {};
return this;
}
/**
* Save the flash storage in preparing to go to the next request
*
* @return MockFlash
*/
function saveFlash(){
variables.mockFlash = getScope();
return this;
}
/**
* Checks if the flash storage exists and IT HAS DATA to inflate.
*/
boolean function flashExists(){
return ( structIsEmpty( variables.mockFlash ) ? false : true );
}
/**
* Get the flash storage structure to inflate it.
*/
struct function getFlash(){
return flashExists() ? variables.mockFlash : {};
}
/**
* Remove the entire flash storage
*
* @return MockFlash
*/
function removeFlash(){
structClear( variables.mockFlash );
return this;
}
}