Changeset 1518

Show
Ignore:
Timestamp:
04/06/08 19:13:02 (1 month ago)
Author:
mikey
Message:

fix bug: stop processing the request if a xml generator cancelled the request

Files:

Legend:

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

    r1513 r1518  
    152152        foreach ($this->xmlGenerators as $xmlGenerator) { 
    153153            $xmlGenerator->generate($xmlStreamWriter, $xmlSerializer); 
     154            if ($this->request->isCancelled() === true) { 
     155                return; 
     156            } 
    154157        } 
    155158 
  • trunk/src/test/php/net/stubbles/websites/xml/stubXMLProcessorTestCase.php

    r1468 r1518  
    184184   public function processSuccessful() 
    185185    { 
     186        $this->mockRequest->expects($this->exactly(3)) 
     187                          ->method('isCancelled') 
     188                          ->will($this->returnValue(false)); 
    186189        $mockXMLGenerator = $this->getMock('stubXMLGenerator'); 
    187190        $this->mockInjector->expects($this->exactly(3))->method('getInstance')->will($this->returnValue($mockXMLGenerator)); 
     
    212215        $this->xmlProcessor->process(); 
    213216    } 
     217 
     218    /** 
     219     * assure that processing works as expected 
     220     * 
     221     * @test 
     222     */ 
     223   public function processCancelledByGenerator() 
     224    { 
     225        $this->mockRequest->expects($this->once()) 
     226                          ->method('isCancelled') 
     227                          ->will($this->returnValue(true)); 
     228        $mockXMLGenerator = $this->getMock('stubXMLGenerator'); 
     229        $this->mockInjector->expects($this->exactly(3))->method('getInstance')->will($this->returnValue($mockXMLGenerator)); 
     230        $mockXMLGenerator->expects($this->once())->method('generate')->with($this->equalTo($this->mockXMLStreamWriter), $this->equalTo($this->mockXMLSerializer)); 
     231        $this->xmlProcessor->expects($this->once())->method('createXMLStreamWriter')->will($this->returnValue($this->mockXMLStreamWriter)); 
     232        $this->xmlProcessor->expects($this->once())->method('createXMLSerializer')->will($this->returnValue($this->mockXMLSerializer)); 
     233        $this->xmlProcessor->expects($this->never())->method('createSkinGenerator'); 
     234        $this->xmlProcessor->expects($this->never())->method('createXSLProcessor'); 
     235        $this->mockXMLStreamWriter->expects($this->never())->method('asDOM'); 
     236        $this->mockXMLStreamWriter->expects($this->never())->method('asXML'); 
     237        $this->mockSession->expects($this->never())->method('putValue'); 
     238        $this->mockResponse->expects($this->never())->method('replaceData'); 
     239        $this->xmlProcessor->process(); 
     240    } 
    214241} 
    215242?>