TestsAppsPostsController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. public function add() {
  25. $this->loadModel('Posts');
  26. $entity = $this->Posts->newEntity($this->request->data);
  27. if ($entity) {
  28. $this->Posts->save($entity);
  29. }
  30. $this->set('posts', $this->Posts->find('all'));
  31. $this->render('index');
  32. }
  33. /**
  34. * check URL params
  35. *
  36. */
  37. public function url_var() {
  38. $this->set('params', $this->request->params);
  39. $this->render('index');
  40. }
  41. /**
  42. * post var testing
  43. *
  44. */
  45. public function post_var() {
  46. $this->set('data', $this->request->data);
  47. $this->render('index');
  48. }
  49. public function input_data() {
  50. $this->set('data', $this->request->input('json_decode', true));
  51. $this->render('index');
  52. }
  53. /**
  54. * Fixturized action for testAction()
  55. *
  56. */
  57. public function fixtured() {
  58. $this->loadModel('Posts');
  59. $this->set('posts', $this->Posts->find('all'));
  60. $this->render('index');
  61. }
  62. }