MyControllerTestCase.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * MyControllerTestCase Test Case
  4. *
  5. */
  6. class MyControllerTestCase extends ControllerTestCase {
  7. /**
  8. * Overwrite to fix issue that it always defaults to POST.
  9. * That should be GET - which it now is.
  10. *
  11. * ### Options:
  12. *
  13. * - `data` Will be used as the request data. If the `method` is GET,
  14. * data will be used a GET params. If the `method` is POST, it will be used
  15. * as POST data. By setting `$options['data']` to a string, you can simulate XML or JSON
  16. * payloads to your controllers allowing you to test REST webservices.
  17. * - `method` POST or GET. Defaults to GET.
  18. * - `return` Specify the return type you want. Choose from:
  19. * - `vars` Get the set view variables.
  20. * - `view` Get the rendered view, without a layout.
  21. * - `contents` Get the rendered view including the layout.
  22. * - `result` Get the return value of the controller action. Useful
  23. * for testing requestAction methods.
  24. *
  25. * @param string $url The url to test
  26. * @param array $options See options
  27. * @return mixed
  28. */
  29. protected function _testAction($url = '', $options = array()) {
  30. $options = array_merge(array(
  31. 'method' => 'GET',
  32. ), $options);
  33. return parent::_testAction($url, $options);
  34. }
  35. }