TestCachedPagesController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace TestApp\Controller;
  3. use Cake\Controller\Controller;
  4. /**
  5. * TestCachedPagesController class
  6. *
  7. */
  8. class TestCachedPagesController extends Controller {
  9. /**
  10. * uses property
  11. *
  12. * @var array
  13. */
  14. public $uses = array();
  15. /**
  16. * helpers property
  17. *
  18. * @var array
  19. */
  20. public $helpers = array('Cache', 'Html');
  21. /**
  22. * cacheAction property
  23. *
  24. * @var array
  25. */
  26. public $cacheAction = array(
  27. 'index' => '+2 sec',
  28. 'test_nocache_tags' => '+2 sec',
  29. 'view' => '+2 sec'
  30. );
  31. /**
  32. * Mock out the response object so it doesn't send headers.
  33. *
  34. * @var string
  35. */
  36. protected $_responseClass = 'Cake\Test\TestCase\Routing\DispatcherMockResponse';
  37. /**
  38. * viewPath property
  39. *
  40. * @var string
  41. */
  42. public $viewPath = 'Posts';
  43. /**
  44. * index method
  45. *
  46. * @return void
  47. */
  48. public function index() {
  49. $this->render();
  50. }
  51. /**
  52. * test_nocache_tags method
  53. *
  54. * @return void
  55. */
  56. public function test_nocache_tags() {
  57. $this->render();
  58. }
  59. /**
  60. * view method
  61. *
  62. * @param $id
  63. * @return void
  64. */
  65. public function view($id = null) {
  66. $this->render('index');
  67. }
  68. /**
  69. * test cached forms / tests view object being registered
  70. *
  71. * @return void
  72. */
  73. public function cache_form() {
  74. $this->cacheAction = 10;
  75. $this->helpers[] = 'Form';
  76. }
  77. /**
  78. * Test cached views with themes.
  79. */
  80. public function themed() {
  81. $this->cacheAction = 10;
  82. $this->theme = 'TestTheme';
  83. }
  84. }