PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/view/assets/imagetag.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 98 lines | 87 code | 11 blank | 0 comment | 0 complexity | 9b650e387e69b6c4eb6c659f241383a4 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cfset loc.controller = controller(name="dummy")>
  4. <cfset loc.args = {}>
  5. <cfset loc.args.source = "../wheels/tests/_assets/files/cfwheels-logo.png">
  6. <cfset loc.args.alt = "wheelstestlogo">
  7. <cfset loc.args.class = "wheelstestlogoclass">
  8. <cfset loc.args.id = "wheelstestlogoid">
  9. <cfset loc.imagePath = application.wheels.webPath & application.wheels.imagePath>
  10. </cffunction>
  11. <cffunction name="test_just_source">
  12. <cfset structdelete(loc.args, "alt")>
  13. <cfset structdelete(loc.args, "class")>
  14. <cfset structdelete(loc.args, "id")>
  15. <cfset loc.r = '<img alt="Cfwheels logo" height="121" src="#loc.imagePath#/#loc.args.source#" width="93" />'>
  16. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  17. <cfset assert("loc.e eq loc.r")>
  18. </cffunction>
  19. <cffunction name="test_supplying_an_alt">
  20. <cfset structdelete(loc.args, "class")>
  21. <cfset structdelete(loc.args, "id")>
  22. <cfset loc.r = '<img alt="#loc.args.alt#" height="121" src="#loc.imagePath#/#loc.args.source#" width="93" />'>
  23. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  24. <cfset assert("loc.e eq loc.r")>
  25. </cffunction>
  26. <cffunction name="test_supplying_an_id_when_caching_is_on">
  27. <cfset loc.cacheImages = application.wheels.cacheImages>
  28. <cfset application.wheels.cacheImages = true>
  29. <cfset StructDelete(loc.args, "alt")>
  30. <cfset StructDelete(loc.args, "class")>
  31. <cfset loc.r = '<img alt="Cfwheels logo" height="121" src="#loc.imagePath#/#loc.args.source#" id="#loc.args.id#" width="93" />'>
  32. <cfset loc.e = loc.controller.imageTag(argumentCollection=loc.args)>
  33. <cfset assert("loc.e eq loc.r")>
  34. <cfset application.wheels.cacheImages = loc.cacheImages>
  35. </cffunction>
  36. <cffunction name="test_supplying_class_and_id">
  37. <cfset loc.r = '<img alt="#loc.args.alt#" class="#loc.args.class#" height="121" src="#loc.imagePath#/#loc.args.source#" id="#loc.args.id#" width="93" />'>
  38. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  39. <cfset assert("loc.e eq loc.r")>
  40. </cffunction>
  41. <cffunction name="test_grabbing_from_http">
  42. <cfset structdelete(loc.args, "alt")>
  43. <cfset structdelete(loc.args, "class")>
  44. <cfset structdelete(loc.args, "id")>
  45. <cfset loc.args.source = "http://www.cfwheels.org/images/cfwheels-logo.png">
  46. <cfset loc.r = '<img alt="Cfwheels logo" src="#loc.args.source#" />'>
  47. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  48. <cfset assert("loc.e eq loc.r")>
  49. </cffunction>
  50. <cffunction name="test_grabbing_from_https">
  51. <cfset structdelete(loc.args, "alt")>
  52. <cfset structdelete(loc.args, "class")>
  53. <cfset structdelete(loc.args, "id")>
  54. <cfset loc.args.source = "https://www.cfwheels.org/images/cfwheels-logo.png">
  55. <cfset loc.r = '<img alt="Cfwheels logo" src="#loc.args.source#" />'>
  56. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  57. <cfset assert("loc.e eq loc.r")>
  58. </cffunction>
  59. <cffunction name="test_specifying_height_and_width">
  60. <cfset structdelete(loc.args, "alt")>
  61. <cfset structdelete(loc.args, "class")>
  62. <cfset structdelete(loc.args, "id")>
  63. <cfset loc.args.height = 25>
  64. <cfset loc.args.width = 25>
  65. <cfset loc.r = '<img alt="Cfwheels logo" height="25" src="#loc.imagePath#/#loc.args.source#" width="25" />'>
  66. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  67. <cfset assert("loc.e eq loc.r")>
  68. </cffunction>
  69. <cffunction name="test_height_only">
  70. <cfset structdelete(loc.args, "alt")>
  71. <cfset structdelete(loc.args, "class")>
  72. <cfset structdelete(loc.args, "id")>
  73. <cfset loc.args.height = 25>
  74. <cfset loc.r = '<img alt="Cfwheels logo" height="25" src="#loc.imagePath#/#loc.args.source#" width="93" />'>
  75. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  76. <cfset assert("loc.e eq loc.r")>
  77. </cffunction>
  78. <cffunction name="test_width_only">
  79. <cfset structdelete(loc.args, "alt")>
  80. <cfset structdelete(loc.args, "class")>
  81. <cfset structdelete(loc.args, "id")>
  82. <cfset loc.args.width = 25>
  83. <cfset loc.r = '<img alt="Cfwheels logo" height="121" src="#loc.imagePath#/#loc.args.source#" width="25" />'>
  84. <cfset loc.e = loc.controller.imageTag(argumentcollection=loc.args)>
  85. <cfset assert("loc.e eq loc.r")>
  86. </cffunction>
  87. </cfcomponent>