function testSetCurrentAction()
  {
    $service = new Service('test');

    $service->setCurrentAction($action = 'test action');

    $this->assertEqual($service->getCurrentAction(),
                       $action);
  }
 function run(&$filter_chain, &$request, &$response)
 {
     $toolkit =& Limb::toolkit();
     if (!($service =& $toolkit->getService())) {
         $filter_chain->next();
         return;
     }
     $service_name = $service->getName();
     $action = $service->getCurrentAction();
     $uri =& $request->getUri();
     $path =& $uri->getPath();
     $acl_toolkit =& Limb::toolkit('SimpleACL');
     $authorizer =& $acl_toolkit->getAuthorizer();
     if ($authorizer->canDo($action, $path, $service_name)) {
         $filter_chain->next();
         return;
     }
     $new_service = new Service('403');
     $new_service->setCurrentAction($new_service->getDefaultAction());
     $toolkit->setService($new_service);
     $filter_chain->next();
 }
 function testRunAccessDenied()
 {
     RegisterTestingIni('403.service.ini', '
                    default_action = display
                    [display]
                    props');
     $toolkit =& Limb::toolkit();
     $request =& $toolkit->getRequest();
     $uri =& $request->getUri();
     $uri->setPath($path = 'whatever');
     $service = new Service($service_name = 'TestService');
     $service->setCurrentAction($action = 'some_action');
     $this->authorizer->expectOnce('canDo', array($action, $path, $service_name));
     $this->authorizer->setReturnValue('canDo', false);
     $filter = new SimpleACLAccessFilter();
     $fc = new MockFilterChain($this);
     $fc->expectOnce('next');
     $toolkit->setService($service);
     $filter->run($fc, $request, $response);
     $new_service =& $toolkit->getService();
     $this->assertEqual($new_service->getName(), '403');
     $this->assertEqual($new_service->getCurrentAction(), 'display');
     $fc->tally();
 }