PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/view/text/excerpt.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 97 lines | 84 code | 13 blank | 0 comment | 0 complexity | 71a91d929106a874bdd0de9a955a2ee0 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.controller = controller(name="dummy")>
 5		<cfset loc.args = {}>
 6		<cfset loc.args.text = "CFWheels: testing the excerpt view helper to see if it works or not.">
 7		<cfset loc.args.phrase = "CFWheels: testing the excerpt">
 8		<cfset loc.args.radius = "0">
 9		<cfset loc.args.excerptString = "[more]">
10	</cffunction>
11
12	<cffunction name="test_find_phrase_at_beginning">
13		<cfset loc.args.phrase = "CFWheels: testing">
14		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
15		<cfset loc.r = "CFWheels: testing[more]">
16		<cfset assert("loc.e eq loc.r")>
17	</cffunction>
18
19	<cffunction name="test_find_phrase_at_end">
20		<cfset loc.args.phrase = "works or not.">
21		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
22		<cfset loc.r = "[more]works or not.">
23		<cfset assert("loc.e eq loc.r")>
24	</cffunction>
25
26	<cffunction name="test_find_phrase_within">
27		<cfset loc.args.phrase = "excerpt view helper">
28		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
29		<cfset loc.r = "[more]excerpt view helper[more]">
30		<cfset assert("loc.e eq loc.r")>
31	</cffunction>
32
33	<cffunction name="test_phrase_not_found">
34		<cfset loc.args.radius = "25">
35		<cfset loc.args.phrase = "jklsduiermobk">
36		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
37		<cfset loc.r = "">
38		<cfset assert("loc.e eq loc.r")>
39	</cffunction>
40
41	<cffunction name="test_radius_does_not_reach_start_or_end">
42		<cfset loc.args.phrase = "excerpt view helper">
43		<cfset loc.args.radius = "10">
44		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
45		<cfset loc.r = "[more]sting the excerpt view helper to see if[more]">
46		<cfset assert("loc.e eq loc.r")>
47	</cffunction>
48
49	<cffunction name="test_radius_reaches_start">
50		<cfset loc.args.phrase = "testing the">
51		<cfset loc.args.radius = "15">
52		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
53		<cfset loc.r = "CFWheels: testing the excerpt view h[more]">
54		<cfset assert("loc.e eq loc.r")>
55	</cffunction>
56
57	<cffunction name="test_radius_reaches_end">
58		<cfset loc.args.radius = "10">
59		<cfset loc.args.phrase = "see if it works">
60		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
61		<cfset loc.r = "[more]helper to see if it works or not.">
62		<cfset assert("loc.e eq loc.r")>
63	</cffunction>
64
65	<cffunction name="test_text_has_html_tags">
66		<cfset loc.args.text = "CFWheels: <p>testing the</p> <b>excerpt</b> <i><b>view</b></i> helper to see if it works or not.">
67		<cfset loc.args.phrase = "excerpt view helper">
68		<cfset loc.args.stripTags = true>
69		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
70		<cfset loc.r = "[more]excerpt view helper[more]">
71		<cfset assert("loc.e eq loc.r")>
72	</cffunction>
73	
74	<cffunction name="test_span_to_whole_words">
75		<cfset loc.args.phrase = "excerpt view helper">
76		<cfset loc.args.radius = 5>
77		<cfset loc.args.wholeWords = true>
78		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
79		<cfset loc.r = "[more]the excerpt view helper to see[more]">
80		<cfset assert("loc.e eq loc.r")>
81		
82		<cfset loc.args.phrase = "works or not.">
83		<cfset loc.args.radius = 5>
84		<cfset loc.args.wholeWords = true>
85		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
86		<cfset loc.r = "[more]if it works or not.">
87		<cfset assert("loc.e eq loc.r")>
88		
89		<cfset loc.args.phrase = "CFWheels: testing">
90		<cfset loc.args.radius = 5>
91		<cfset loc.args.wholeWords = true>
92		<cfset loc.e = loc.controller.excerpt(argumentcollection=loc.args)>
93		<cfset loc.r = "CFWheels: testing the excerpt[more]">
94		<cfset assert("loc.e eq loc.r")>
95	</cffunction>
96
97</cfcomponent>