Skip to content

Commit

Permalink
ActionController should not default to index
Browse files Browse the repository at this point in the history
- If no action is present, default to not-found
  • Loading branch information
weierophinney committed Feb 14, 2012
1 parent 34bc3d7 commit 878cb78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Mvc/Controller/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function execute(MvcEvent $e)
throw new \DomainException('Missing route matches; unsure how to retrieve action');
}

$action = $routeMatch->getParam('action', 'index');
$action = $routeMatch->getParam('action', 'not-found');
$method = static::getMethodFromAction($action);

if (!method_exists($this, $method)) {
Expand Down
6 changes: 4 additions & 2 deletions tests/Zend/Mvc/Controller/ActionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public function setUp()
StaticEventManager::resetInstance();
}

public function testDispatchInvokesIndexActionWhenNoActionPresentInRouteMatch()
public function testDispatchInvokesNotFoundActionWhenNoActionPresentInRouteMatch()
{
$result = $this->controller->dispatch($this->request, $this->response);
$response = $this->controller->getResponse();
$this->assertEquals(404, $response->getStatusCode());
$this->assertTrue(isset($result['content']));
$this->assertContains('Placeholder page', $result['content']);
$this->assertContains('Page not found', $result['content']);
}

public function testDispatchInvokesNotFoundActionWhenInvalidActionPresentInRouteMatch()
Expand Down

0 comments on commit 878cb78

Please sign in to comment.