Skip to content

Commit

Permalink
Add @trigger to functions docs when event added
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Warner committed Nov 30, 2014
1 parent 4a8e757 commit 26b9d94
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Error/ExceptionRenderer.php
Expand Up @@ -95,6 +95,7 @@ public function __construct(Exception $exception) {
* a bare controller will be used.
*
* @return \Cake\Controller\Controller
* @triggers Controller.startup $controller
*/
protected function _getController() {
if (!$request = Router::getRequest(true)) {
Expand Down
1 change: 1 addition & 0 deletions src/Event/EventManager.php
Expand Up @@ -215,6 +215,7 @@ protected function _detachSubscriber(EventListenerInterface $subscriber, $eventK
*
* @param string|\Cake\Event\Event $event the event key name or instance of Event
* @return \Cake\Event\Event
* @triggers $event
*/
public function dispatch($event) {
if (is_string($event)) {
Expand Down
1 change: 1 addition & 0 deletions src/Shell/Task/TemplateTask.php
Expand Up @@ -48,6 +48,7 @@ class TemplateTask extends Shell {
* Get view instance
*
* @return \Cake\View\View
* @triggers Bake.initialize $view
*/
public function getView() {
if ($this->View) {
Expand Down
21 changes: 21 additions & 0 deletions tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -103,6 +103,7 @@ public function testNoAuth() {
* testIsErrorOrTests
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testIsErrorOrTests() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -159,6 +160,7 @@ public function testIdentify() {
* testRedirectVarClearing method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testRedirectVarClearing() {
$this->Controller->request['controller'] = 'auth_test';
Expand All @@ -180,6 +182,7 @@ public function testRedirectVarClearing() {
* testAuthorizeFalse method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAuthorizeFalse() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -374,6 +377,7 @@ public function testSameAuthenticateWithDifferentHashers() {
* Tests that deny always takes precedence over allow
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAllowDenyAll() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -433,6 +437,7 @@ public function testAllowDenyAll() {
* test that deny() converts camel case inputs to lowercase.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testDenyWithCamelCaseMethods() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -455,6 +460,7 @@ public function testDenyWithCamelCaseMethods() {
* test that allow() and allowedActions work with camelCase method names.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAllowedActionsWithCamelCaseMethods() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -507,6 +513,7 @@ public function testAllowedActionsSetWithAllowMethod() {
* testLoginRedirect method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testLoginRedirect() {
$url = '/auth_test/camelCase';
Expand Down Expand Up @@ -652,6 +659,7 @@ public function testLoginRedirect() {
* testNoLoginRedirectForAuthenticatedUser method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testNoLoginRedirectForAuthenticatedUser() {
$this->Controller->request['controller'] = 'auth_test';
Expand All @@ -678,6 +686,7 @@ public function testNoLoginRedirectForAuthenticatedUser() {
* Default to loginRedirect, if set, on authError.
*
* @return void
* @triggers Controller.startup $Controller
*/
public function testDefaultToLoginRedirect() {
$url = '/party/on';
Expand Down Expand Up @@ -709,6 +718,7 @@ public function testDefaultToLoginRedirect() {
* testRedirectToUnauthorizedRedirect
*
* @return void
* @triggers Controller.startup $Controller
*/
public function testRedirectToUnauthorizedRedirect() {
$url = '/party/on';
Expand Down Expand Up @@ -750,6 +760,7 @@ public function testRedirectToUnauthorizedRedirect() {
* testRedirectToUnauthorizedRedirectSuppressedAuthError
*
* @return void
* @triggers Controller.startup $Controller
*/
public function testRedirectToUnauthorizedRedirectSuppressedAuthError() {
$url = '/party/on';
Expand Down Expand Up @@ -788,6 +799,7 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() {
*
* @expectedException \Cake\Network\Exception\ForbiddenException
* @return void
* @triggers Controller.startup $Controller
*/
public function testForbiddenException() {
$url = '/party/on';
Expand All @@ -814,6 +826,7 @@ public function testForbiddenException() {
* Test that no redirects or authorization tests occur on the loginAction
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testNoRedirectOnLoginAction() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -839,6 +852,7 @@ public function testNoRedirectOnLoginAction() {
* And the user doesn't have a session.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testNoRedirectOn404() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -852,6 +866,7 @@ public function testNoRedirectOn404() {
* testAdminRoute method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAdminRoute() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -884,6 +899,7 @@ public function testAdminRoute() {
* testAjaxLogin method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAjaxLogin() {
$this->Controller->request = new Request([
Expand All @@ -910,6 +926,7 @@ public function testAjaxLogin() {
* testLoginActionRedirect method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testLoginActionRedirect() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -952,6 +969,7 @@ public function testLoginActionRedirect() {
* accessed by $this->user().
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStatelessAuthWorksWithUser() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down Expand Up @@ -1077,6 +1095,7 @@ public function testGettingUserAfterSetUser() {
* test flash settings.
*
* @return void
* @triggers Controller.startup $this->Controller)
*/
public function testFlashSettings() {
$this->Auth->Flash = $this->getMock(
Expand Down Expand Up @@ -1261,6 +1280,7 @@ public function testUser() {
* @expectedException \Cake\Network\Exception\UnauthorizedException
* @expectedExceptionCode 401
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStatelessAuthNoRedirect() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -1277,6 +1297,7 @@ public function testStatelessAuthNoRedirect() {
* testStatelessAuthRedirect method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStatelessFollowedByStatefulAuth() {
$event = new Event('Controller.startup', $this->Controller);
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase/Controller/Component/CsrfComponentTest.php
Expand Up @@ -53,6 +53,7 @@ public function tearDown() {
* Test setting the cookie value
*
* @return void
* @triggers Controller.startup $controller
*/
public function testSettingCookie() {
$_SERVER['REQUEST_METHOD'] = 'GET';
Expand Down Expand Up @@ -89,6 +90,7 @@ public static function httpMethodProvider() {
*
* @dataProvider httpMethodProvider
* @return void
* @triggers Controller.startup $controller
*/
public function testValidTokenInHeader($method) {
$_SERVER['REQUEST_METHOD'] = $method;
Expand All @@ -109,6 +111,7 @@ public function testValidTokenInHeader($method) {
* @dataProvider httpMethodProvider
* @expectedException \Cake\Network\Exception\ForbiddenException
* @return void
* @triggers Controller.startup $controller
*/
public function testInvalidTokenInHeader($method) {
$_SERVER['REQUEST_METHOD'] = $method;
Expand All @@ -129,6 +132,7 @@ public function testInvalidTokenInHeader($method) {
*
* @dataProvider httpMethodProvider
* @return void
* @triggers Controller.startup $controller
*/
public function testValidTokenRequestData($method) {
$_SERVER['REQUEST_METHOD'] = $method;
Expand All @@ -151,6 +155,7 @@ public function testValidTokenRequestData($method) {
* @dataProvider httpMethodProvider
* @expectedException \Cake\Network\Exception\ForbiddenException
* @return void
* @triggers Controller.startup $controller
*/
public function testInvalidTokenRequestData($method) {
$_SERVER['REQUEST_METHOD'] = $method;
Expand All @@ -170,6 +175,7 @@ public function testInvalidTokenRequestData($method) {
* Test that CSRF checks are not applied to request action requests.
*
* @return void
* @triggers Controller.startup $controller
*/
public function testCsrfValidationSkipsRequestAction() {
$_SERVER['REQUEST_METHOD'] = 'POST';
Expand All @@ -192,6 +198,7 @@ public function testCsrfValidationSkipsRequestAction() {
* Test that the configuration options work.
*
* @return void
* @triggers Controller.startup $controller
*/
public function testConfigurationCookieCreate() {
$_SERVER['REQUEST_METHOD'] = 'GET';
Expand Down Expand Up @@ -222,6 +229,7 @@ public function testConfigurationCookieCreate() {
* Test that the configuration options work.
*
* @return void
* @triggers Controller.startup $controller
*/
public function testConfigurationValidate() {
$_SERVER['REQUEST_METHOD'] = 'POST';
Expand Down
Expand Up @@ -314,6 +314,7 @@ public function testViewClassMap() {
* Verify that isAjax is set on the request params for ajax requests
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testIsAjaxParams() {
$this->request->env('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
Expand All @@ -328,6 +329,7 @@ public function testIsAjaxParams() {
* testAutoAjaxLayout method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAutoAjaxLayout() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -349,6 +351,7 @@ public function testAutoAjaxLayout() {
* test custom JsonView class is loaded and correct.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testJsonViewLoaded() {
Router::extensions(['json', 'xml', 'ajax'], false);
Expand All @@ -366,6 +369,7 @@ public function testJsonViewLoaded() {
* test custom XmlView class is loaded and correct.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testXmlViewLoaded() {
Router::extensions(['json', 'xml', 'ajax'], false);
Expand All @@ -383,6 +387,7 @@ public function testXmlViewLoaded() {
* test custom AjaxView class is loaded and correct.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAjaxViewLoaded() {
Router::extensions(['json', 'xml', 'ajax'], false);
Expand All @@ -399,6 +404,7 @@ public function testAjaxViewLoaded() {
* test configured extension but no view class set.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testNoViewClassExtension() {
Router::extensions(['json', 'xml', 'ajax', 'csv'], false);
Expand All @@ -414,6 +420,7 @@ public function testNoViewClassExtension() {
* testStartupCallback method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStartupCallback() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -429,6 +436,7 @@ public function testStartupCallback() {
* testStartupCallback with charset.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStartupCallbackCharset() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -444,6 +452,7 @@ public function testStartupCallbackCharset() {
* Test mapping a new type and having startup process it.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStartupCustomTypeProcess() {
if (!function_exists('str_getcsv')) {
Expand All @@ -468,6 +477,7 @@ public function testStartupCustomTypeProcess() {
* testNonAjaxRedirect method
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testNonAjaxRedirect() {
$event = new Event('Controller.startup', $this->Controller);
Expand All @@ -480,6 +490,7 @@ public function testNonAjaxRedirect() {
* test that redirects with ajax and no URL don't do anything.
*
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testAjaxRedirectWithNoUrl() {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
Expand Down Expand Up @@ -746,6 +757,7 @@ public function testPrefers() {
* test that ajax requests involving redirects trigger requestAction instead.
*
* @return void
* @triggers Controller.beforeRedirect $this->Controller
*/
public function testAjaxRedirectAsRequestAction() {
Configure::write('App.namespace', 'TestApp');
Expand Down Expand Up @@ -775,6 +787,7 @@ public function testAjaxRedirectAsRequestAction() {
* this would cause the ajax layout to not be rendered.
*
* @return void
* @triggers Controller.beforeRedirect $this->Controller
*/
public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
Configure::write('App.namespace', 'TestApp');
Expand Down Expand Up @@ -807,6 +820,7 @@ public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
*
* @link https://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/276
* @return void
* @triggers Controller.beforeRender $this->Controller
*/
public function testBeforeRedirectCallbackWithArrayUrl() {
Configure::write('App.namespace', 'TestApp');
Expand Down Expand Up @@ -847,6 +861,7 @@ public function testAddInputTypeException() {
* Test checkNotModified method
*
* @return void
* @triggers Controller.beforeRender $this->Controller
*/
public function testCheckNotModifiedByEtagStar() {
$_SERVER['HTTP_IF_NONE_MATCH'] = '*';
Expand All @@ -862,6 +877,7 @@ public function testCheckNotModifiedByEtagStar() {
* Test checkNotModified method
*
* @return void
* @triggers Controller.beforeRender
*/
public function testCheckNotModifiedByEtagExact() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
Expand All @@ -877,6 +893,7 @@ public function testCheckNotModifiedByEtagExact() {
* Test checkNotModified method
*
* @return void
* @triggers Controller.beforeRender $this->Controller
*/
public function testCheckNotModifiedByEtagAndTime() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
Expand All @@ -894,6 +911,7 @@ public function testCheckNotModifiedByEtagAndTime() {
* Test checkNotModified method
*
* @return void
* @triggers Controller.beforeRender $this->Controller
*/
public function testCheckNotModifiedNoInfo() {
$event = new Event('Controller.beforeRender', $this->Controller);
Expand Down

0 comments on commit 26b9d94

Please sign in to comment.