Changeset 1533

Show
Ignore:
Timestamp:
04/12/08 18:35:23 (1 month ago)
Author:
mikey
Message:

stop further processing if request already canceled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r1531 r1533  
    116116    public function process() 
    117117    { 
     118        if ($this->request->isCancelled() === true) { 
     119            $this->response->send(); 
     120            return; 
     121        } 
     122         
    118123        $processorResolverFactory = $this->websiteInitializer->getProcessorResolverFactory(); 
    119124        $processorResolverFactory->init(); 
  • trunk/src/test/php/net/stubbles/websites/stubFrontControllerTestCase.php

    r1464 r1533  
    150150     * @test 
    151151     */ 
     152    public function processWithAlreadyCancelledRequest() 
     153    { 
     154        $this->mockRequest->expects($this->once())->method('isCancelled')->will($this->returnValue(true)); 
     155        $this->mockResponse->expects($this->once())->method('send'); 
     156        $this->mockProcessor->expects($this->never())->method('forceSSL'); 
     157        $this->mockInterceptorInitializer->expects($this->never())->method('getPreInterceptors'); 
     158        $this->mockInterceptorInitializer->expects($this->never())->method('getPostInterceptors'); 
     159        $this->mockProcessor->expects($this->never())->method('getInterceptorDescriptor'); 
     160        $this->mockProcessor->expects($this->never())->method('process'); 
     161        $this->mockWebsiteCacheFactory->expects($this->never())->method('configure'); 
     162        $this->frontController->setWebsiteCacheFactory($this->mockWebsiteCacheFactory); 
     163        $this->frontController->process(); 
     164    } 
     165 
     166    /** 
     167     * assure that processing ends when request is cancelled 
     168     * 
     169     * @test 
     170     */ 
    152171    public function processWithPreInterceptorCancellingRequest() 
    153172    { 
     
    161180                                         ->will($this->returnValue(array($preInterceptor1, $preInterceptor2))); 
    162181        $this->mockInterceptorInitializer->expects($this->never())->method('getPostInterceptors'); 
    163         $this->mockRequest->expects($this->once())->method('isCancelled')->will($this->returnValue(true)); 
     182        $this->mockRequest->expects($this->exactly(2))->method('isCancelled')->will($this->onConsecutiveCalls(false, true)); 
    164183        $this->mockResponse->expects($this->once())->method('send'); 
    165184        $this->mockProcessor->expects($this->once()) 
     
    189208        $this->mockInterceptorInitializer->expects($this->never()) 
    190209                                         ->method('getPostInterceptors'); 
    191         $this->mockRequest->expects($this->once())->method('isCancelled')->will($this->returnValue(true)); 
     210        $this->mockRequest->expects($this->exactly(2))->method('isCancelled')->will($this->onConsecutiveCalls(false, true)); 
    192211        $this->mockProcessor->expects($this->any())->method('process'); 
    193212        $this->mockResponse->expects($this->once())->method('send'); 
     
    213232                                         ->method('getPostInterceptors') 
    214233                                         ->will($this->returnValue(array($postInterceptor1, $postInterceptor2))); 
    215         $this->mockRequest->expects($this->exactly(2)) 
     234        $this->mockRequest->expects($this->exactly(3)) 
    216235                          ->method('isCancelled') 
    217                           ->will($this->onConsecutiveCalls(false, true)); 
     236                          ->will($this->onConsecutiveCalls(false, false, true)); 
    218237        $this->mockProcessor->expects($this->any())->method('process'); 
    219238        $this->mockResponse->expects($this->once())->method('send');