PHP容器化demo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.5 KiB

3 years ago
  1. <?php
  2. /**
  3. * Input.test.php
  4. * Test Base controller.
  5. * @version 150629:1
  6. * @author karminski <code.karminski@outlook.com>
  7. *
  8. */
  9. require(dirname(__FILE__).'/../protected/lib/base/Input.php');
  10. $input_param = array(
  11. array(
  12. 'param' => 'id',
  13. 'condition' => array(
  14. 'method' => null,
  15. 'type' => Input::TYPE_INT,
  16. 'limit' => array('min' => 0, 'max' => 100000000),
  17. 'default' => 0,
  18. 'necessary' => true,
  19. ),
  20. ),
  21. array(
  22. 'param' => 'type',
  23. 'condition' => array(
  24. 'method' => null,
  25. 'type' => Input::TYPE_ENUM,
  26. 'options' => array("a", "b", "c", 0),
  27. 'default' => 0,
  28. 'necessary' => true,
  29. ),
  30. ),
  31. array(
  32. 'param' => 'data',
  33. 'condition' => array(
  34. 'method' => null,
  35. 'type' => Input::TYPE_STRING,
  36. 'sub_type' => Input::TYPE_STRING,
  37. 'limit' => array('fixed' => 32),
  38. 'default' => null,
  39. 'necessary' => true,
  40. ),
  41. ),
  42. array(
  43. 'param' => 'token',
  44. 'condition' => array(
  45. 'method' => null,
  46. 'type' => Input::TYPE_STRING,
  47. 'limit' => array('fixed' => 32),
  48. 'default' => '',
  49. 'necessary' => true,
  50. ),
  51. ),
  52. array(
  53. 'param' => 'callback',
  54. 'condition' => array(
  55. 'method' => null,
  56. 'type' => Input::TYPE_STRING,
  57. 'limit' => array('min' => 1, 'max' => 40),
  58. 'default' => '',
  59. 'necessary' => false,
  60. ),
  61. ),
  62. array(
  63. 'param' => 'src',
  64. 'condition' => array(
  65. 'method' => null,
  66. 'type' => Input::TYPE_STRING,
  67. 'limit' => array('min' => 1, 'max' => 40),
  68. 'default' => '',
  69. 'necessary' => false,
  70. ),
  71. ),
  72. );
  73. $_GET = array(
  74. 'id' => 12,
  75. 'type' => 'a',
  76. 'callback' => 'json_callback_21453534534',
  77. 'src' => 'pc_452345',
  78. );
  79. $r = array();
  80. $exp = array();
  81. Input::get(Input::METHOD_GET, $input_param, $r, $exp);
  82. var_dump($r);
  83. var_dump($exp);