TestsAppsPostsController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * TestsAppsPostsController file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8. * Copyright 2005-2012, 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-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  15. * @package Cake.Test.test_app.Controller
  16. * @since CakePHP(tm) v 1.2.0.4206
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. class TestsAppsPostsController extends AppController {
  20. public $name = 'TestsAppsPosts';
  21. public $uses = array('Post');
  22. public $viewPath = 'TestsApps';
  23. public function add() {
  24. $data = array(
  25. 'Post' => array(
  26. 'title' => 'Test article',
  27. 'body' => 'Body of article.',
  28. 'author_id' => 1
  29. )
  30. );
  31. $this->Post->save($data);
  32. $this->set('posts', $this->Post->find('all'));
  33. $this->render('index');
  34. }
  35. /**
  36. * check url params
  37. *
  38. */
  39. public function url_var() {
  40. $this->set('params', $this->request->params);
  41. $this->render('index');
  42. }
  43. /**
  44. * post var testing
  45. *
  46. */
  47. public function post_var() {
  48. $this->set('data', $this->request->data);
  49. $this->render('index');
  50. }
  51. public function input_data() {
  52. $this->set('data', $this->request->input('json_decode', true));
  53. $this->render('index');
  54. }
  55. /**
  56. * Fixturized action for testAction()
  57. *
  58. */
  59. public function fixtured() {
  60. $this->set('posts', $this->Post->find('all'));
  61. $this->render('index');
  62. }
  63. }