RequestActionController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * RequestActionController file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
  15. * @since 3.0.0
  16. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  17. */
  18. namespace TestApp\Controller;
  19. /**
  20. * RequestActionController class
  21. *
  22. */
  23. class RequestActionController extends AppController {
  24. /**
  25. * modelClass property
  26. *
  27. * @var string
  28. */
  29. public $modelClass = 'Posts';
  30. /**
  31. * test_request_action method
  32. *
  33. * @return \Cake\Network\Response
  34. */
  35. public function test_request_action() {
  36. $this->response->body('This is a test');
  37. return $this->response;
  38. }
  39. /**
  40. * another_ra_test method
  41. *
  42. * @param mixed $id
  43. * @param mixed $other
  44. * @return \Cake\Network\Response
  45. */
  46. public function another_ra_test($id, $other) {
  47. $this->response->body($id + $other);
  48. return $this->response;
  49. }
  50. /**
  51. * normal_request_action method
  52. *
  53. * @return \Cake\Network\Response
  54. */
  55. public function normal_request_action() {
  56. $this->response->body('Hello World');
  57. return $this->response;
  58. }
  59. /**
  60. * returns $this->here as body
  61. *
  62. * @return \Cake\Network\Response
  63. */
  64. public function return_here() {
  65. $this->response->body($this->here);
  66. return $this->response;
  67. }
  68. /**
  69. * paginate_request_action method
  70. *
  71. * @return void
  72. */
  73. public function paginate_request_action() {
  74. $data = $this->paginate();
  75. }
  76. /**
  77. * post pass, testing post passing
  78. *
  79. * @return array
  80. */
  81. public function post_pass() {
  82. return $this->request->data;
  83. }
  84. /**
  85. * query pass, testing query passing
  86. *
  87. * @return array
  88. */
  89. public function query_pass() {
  90. return $this->request->query;
  91. }
  92. /**
  93. * test param passing and parsing.
  94. *
  95. * @return array
  96. */
  97. public function params_pass() {
  98. return $this->request;
  99. }
  100. /**
  101. * param check method.
  102. *
  103. * @return void
  104. */
  105. public function param_check() {
  106. $this->autoRender = false;
  107. $content = '';
  108. if (isset($this->request->params[0])) {
  109. $content = 'return found';
  110. }
  111. $this->response->body($content);
  112. }
  113. }