PageRenderTime 364ms CodeModel.GetById 161ms app.highlight 1ms RepoModel.GetById 200ms app.codeStats 0ms

/wheels/tests/controller/miscellaneous/sendmail.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 74 lines | 62 code | 12 blank | 0 comment | 0 complexity | 2319ed86f9b4dea3e6c821ecb231b5e5 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cfset params = {controller="test", action="test"}>
 4	<cfset loc.controller = controller("dummy", params)>
 5
 6	<cffunction name="setup">
 7		<cfset args = StructNew()>
 8		<cfset args.subject = "dummy subject">
 9		<cfset args.to = "to-dummy@dummy.com">
10		<cfset args.from = "from-dummy@dummy.com">
11		<cfset args.$deliver = false>
12		<cfset oldViewPath = application.wheels.viewPath>
13		<cfset application.wheels.viewPath = "wheels/tests/_assets/views">
14		<cfset oldFilePath = application.wheels.filePath>
15		<cfset application.wheels.filePath = "wheels/tests/_assets/files">
16	</cffunction>
17
18	<cffunction name="test_send_plain">
19		<cfset args.template = "plainEmailTemplate">
20		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
21		<cfset assert("ListLen(StructKeyList(result)) IS 5 AND StructKeyExists(result, 'to') AND StructKeyExists(result, 'from') AND StructKeyExists(result, 'subject') AND result.type IS 'text' AND result.tagContent IS 'dummy plain email body'")>
22	</cffunction>
23
24	<cffunction name="test_send_html">
25		<cfset args.template = "HTMLEmailTemplate">
26		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
27		<cfset assert("result.type IS 'html' AND result.tagContent IS '<p>dummy html email body</p>'")>
28	</cffunction>
29
30	<cffunction name="test_send_combined_in_correct_order">
31		<cfset args.templates = "HTMLEmailTemplate,plainEmailTemplate">
32		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
33		<cfset assert("result.mailparts[1].type IS 'text' AND result.mailparts[2].tagContent IS '<p>dummy html email body</p>'")>
34	</cffunction>
35
36	<cffunction name="test_send_with_layout">
37		<cfset args.template = "HTMLEmailTemplate">
38		<cfset args.layout = "emailLayout">
39		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
40		<cfset assert("result.tagContent Contains '<div>'")>
41	</cffunction>
42
43	<cffunction name="test_send_with_attachment">
44		<cfset args.template = "plainEmailTemplate">
45		<cfset args.file = "cfwheels-logo.png">
46		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
47		<cfset assert("result.mailparams[1].file Contains '_assets' AND result.mailparams[1].file Contains 'cfwheels-logo.png'")>
48	</cffunction>
49
50	<cffunction name="test_send_with_custom_argument">
51		<cfset args.template = "plainEmailTemplate">
52		<cfset args.customArgument = "IPassedInThisAsACustomArgument">
53		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
54		<cfset assert("result.tagContent Contains 'IPassedInThisAsACustomArgument'")>
55	</cffunction>
56
57	<cffunction name="test_send_from_different_path">
58		<cfset args.template = "/shared/anotherPlainEmailTemplate">
59		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
60		<cfset assert("result.tagContent IS 'another dummy plain email body'")>
61	</cffunction>
62
63	<cffunction name="test_send_from_sub_folder">
64		<cfset args.template = "sub/anotherHTMLEmailTemplate">
65		<cfset result = loc.controller.sendEmail(argumentCollection=args)>
66		<cfset assert("result.tagContent IS '<p>another dummy html email body</p>'")>
67	</cffunction>
68
69	<cffunction name="teardown">
70		<cfset application.wheels.viewPath = oldViewPath>
71		<cfset application.wheels.filePath = oldFilePath>
72	</cffunction>
73
74</cfcomponent>