TestsAppsPostsController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * @package Cake.Test.TestApp.Controller
  15. * @since CakePHP(tm) v 1.2.0.4206
  16. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  17. */
  18. /**
  19. * Class TestsAppsPostsController
  20. *
  21. * @package Cake.Test.TestApp.Controller
  22. */
  23. class TestsAppsPostsController extends AppController {
  24. public $uses = array('Post');
  25. public $viewPath = 'TestsApps';
  26. /**
  27. * add method
  28. *
  29. * @return void
  30. */
  31. public function add() {
  32. $data = array(
  33. 'Post' => array(
  34. 'title' => 'Test article',
  35. 'body' => 'Body of article.',
  36. 'author_id' => 1
  37. )
  38. );
  39. $this->Post->save($data);
  40. $this->set('posts', $this->Post->find('all'));
  41. $this->render('index');
  42. }
  43. /**
  44. * check URL params
  45. *
  46. * @return void
  47. */
  48. public function url_var() {
  49. $this->set('params', $this->request->params);
  50. $this->render('index');
  51. }
  52. /**
  53. * post var testing
  54. *
  55. * @return void
  56. */
  57. public function post_var() {
  58. $this->set('data', $this->request->data);
  59. $this->render('index');
  60. }
  61. /**
  62. * input_data()
  63. *
  64. * @return void
  65. */
  66. public function input_data() {
  67. $this->set('data', $this->request->input('json_decode', true));
  68. $this->render('index');
  69. }
  70. /**
  71. * Fixturized action for testAction()
  72. *
  73. * @return void
  74. */
  75. public function fixtured() {
  76. $this->set('posts', $this->Post->find('all'));
  77. $this->render('index');
  78. }
  79. }