TestsAppsPostsController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * TestsAppsPostsController file
  4. *
  5. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  14. * @since 1.2.0
  15. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  16. */
  17. /**
  18. * Class TestsAppsPostsController
  19. *
  20. */
  21. namespace TestApp\Controller;
  22. class TestsAppsPostsController extends AppController {
  23. public $viewPath = 'TestsApps';
  24. /**
  25. * add method
  26. *
  27. * @return void
  28. */
  29. public function add() {
  30. $this->loadModel('Posts');
  31. $entity = $this->Posts->newEntity($this->request->data);
  32. if ($entity) {
  33. $this->Posts->save($entity);
  34. }
  35. $this->set('posts', $this->Posts->find('all'));
  36. $this->render('index');
  37. }
  38. /**
  39. * check URL params
  40. *
  41. * @return void
  42. */
  43. public function url_var() {
  44. $this->set('params', $this->request->params);
  45. $this->render('index');
  46. }
  47. /**
  48. * post var testing
  49. *
  50. * @return void
  51. */
  52. public function post_var() {
  53. $this->set('data', $this->request->data);
  54. $this->render('index');
  55. }
  56. /**
  57. * input_data()
  58. *
  59. * @return void
  60. */
  61. public function input_data() {
  62. $this->set('data', $this->request->input('json_decode', true));
  63. $this->render('index');
  64. }
  65. /**
  66. * Fixturized action for testAction()
  67. *
  68. * @return void
  69. */
  70. public function fixtured() {
  71. $this->loadModel('Posts');
  72. $this->set('posts', $this->Posts->find('all'));
  73. $this->render('index');
  74. }
  75. }