PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/model/miscellaneous/setPagination.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 43 lines | 35 code | 8 blank | 0 comment | 0 complexity | a32b72c1616558b995796daca7730529 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cfset loc.user = model("user")>
  4. </cffunction>
  5. <cffunction name="test_only_totalRecords">
  6. <cfset loc.user.setPagination(100)>
  7. <cfset assert_pagination(handle="query", totalRecords=100)>
  8. </cffunction>
  9. <cffunction name="test_all_arguments">
  10. <cfset loc.user.setPagination(1000, 4, 50, "pageTest")>
  11. <cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=4, perPage=50)>
  12. </cffunction>
  13. <cffunction name="test_totalRecords_less_than_zero">
  14. <cfset loc.user.setPagination(-5, 4, 50, "pageTest")>
  15. <cfset assert_pagination(handle="pageTest", totalRecords=0, currentPage=1, perPage=50)>
  16. </cffunction>
  17. <cffunction name="test_currentPage_less_than_one">
  18. <cfset loc.user.setPagination(1000, -4, 50, "pageTest")>
  19. <cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=1, perPage=50)>
  20. </cffunction>
  21. <cffunction name="test_numeric_arguments_must_be_integers">
  22. <cfset loc.user.setPagination(1000.9998, 5.876, 50.847, "pageTest")>
  23. <cfset assert_pagination(handle="pageTest", totalRecords=1000, currentPage=5, perPage=50)>
  24. </cffunction>
  25. <cffunction name="assert_pagination">
  26. <cfargument name="handle" type="string" required="true">
  27. <cfset loc.args = arguments>
  28. <cfset assert('StructKeyExists(request.wheels, loc.args.handle)')>
  29. <cfset loc.p = request.wheels[loc.args.handle]>
  30. <cfset StructDelete(loc.args, "handle", false)>
  31. <cfloop collection="#loc.args#" item="loc.i">
  32. <cfset assert('loc.p[loc.i] eq loc.args[loc.i]')>
  33. </cfloop>
  34. </cffunction>
  35. </cfcomponent>