Changeset 868
- Timestamp:
- 08/22/07 16:13:58 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/websites/xml/stubShowLastXMLInterceptor.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLPreInterceptor.php (deleted)
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/xml/stubShowLastXMLInterceptorTestCase.php (copied) (copied from trunk/src/test/php/net/stubbles/websites/xml/stubXMLPreInterceptorTestCase.php) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/xml/stubShowLastXMLInterceptor.php
r473 r868 41 41 { 42 42 /** 43 * key with which last xml is stored in session 44 */ 45 const SESSION_KEY = 'net.stubbles.websites.lastRequestResponseData'; 46 47 /** 43 48 * does the preprocessing stuff 44 49 * … … 51 56 if ($request->hasValue('showLastRequestXML') == true && $session->isNew() == false) { 52 57 $response->addHeader('Content-type', 'text/xml'); 53 $response->write($session->getValue( 'net.stubbles.websites.lastRequestResponseData'));58 $response->write($session->getValue(self::SESSION_KEY)); 54 59 $request->cancel(); 55 60 } … … 65 70 public function postProcess(stubRequest $request, stubSession $session, stubResponse $response) 66 71 { 67 $session->putValue( 'net.stubbles.websites.lastRequestResponseData', $response->getData());72 $session->putValue(self::SESSION_KEY, $response->getData()); 68 73 } 69 74 } trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r811 r868 37 37 38 38 // xml tests 39 $this->addTestFile($dir . '/xml/stubShowLastXMLInterceptorTestCase.php'); 39 40 $this->addTestFile($dir . '/xml/stubXMLPostInterceptorTestCase.php'); 40 $this->addTestFile($dir . '/xml/stubXMLPreInterceptorTestCase.php');41 41 $this->addTestFile($dir . '/xml/stubXMLProcessorTestCase.php'); 42 42 $this->addTestFile($dir . '/xml/stubXMLResponseTestCase.php'); trunk/src/test/php/net/stubbles/websites/xml/stubShowLastXMLInterceptorTestCase.php
r473 r868 1 1 <?php 2 2 /** 3 * Tests for net.stubbles.websites.xml.stub XMLPreInterceptor3 * Tests for net.stubbles.websites.xml.stubShowLastXMLInterceptor. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 7 7 * @subpackage websites_xml_test 8 8 */ 9 stubClassLoader::load('net.stubbles.websites.xml.stub XMLPreInterceptor');9 stubClassLoader::load('net.stubbles.websites.xml.stubShowLastXMLInterceptor'); 10 10 Mock::generate('stubRequest'); 11 11 Mock::generate('stubResponse'); 12 12 Mock::generate('stubSession'); 13 13 /** 14 * Tests for net.stubbles.websites.xml.stub XMLPreInterceptor14 * Tests for net.stubbles.websites.xml.stubShowLastXMLInterceptor. 15 15 * 16 16 * @package stubbles 17 17 * @subpackage websites_xml_test 18 18 */ 19 class stub XMLPreInterceptorTestCase extends UnitTestCase19 class stubShowLastXMLInterceptorTestCase extends UnitTestCase 20 20 { 21 21 /** 22 22 * instance to test 23 23 * 24 * @var stub XMLPreInterceptor24 * @var stubShowLastXMLInterceptor 25 25 */ 26 protected $ xmlPreInterceptor;26 protected $showLastXMLPreInterceptor; 27 27 /** 28 28 * mocked response instance … … 43 43 */ 44 44 protected $mockSession; 45 45 46 46 /** 47 47 * set up test environment … … 49 49 public function setUp() 50 50 { 51 $this-> xmlPreInterceptor = new stubXMLPreInterceptor();52 $this->mockRequest = new MockstubRequest();53 $this->mockResponse = new MockstubResponse();54 $this->mockSession = new MockstubSession();51 $this->showLastXMLPreInterceptor = new stubShowLastXMLInterceptor(); 52 $this->mockRequest = new MockstubRequest(); 53 $this->mockResponse = new MockstubResponse(); 54 $this->mockSession = new MockstubSession(); 55 55 } 56 56 57 57 /** 58 58 * assure that a new session does not trigger the interceptor … … 63 63 $this->mockSession->setReturnValue('isNew', true); 64 64 $this->mockRequest->expectNever('cancel'); 65 $this->xmlPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 65 $this->mockResponse->expectNever('write'); 66 $this->showLastXMLPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 66 67 } 67 68 68 69 /** 69 70 * assure that a request that does not force to show the last request xml does not trigger the interceptor … … 74 75 $this->mockSession->setReturnValue('isNew', false); 75 76 $this->mockRequest->expectNever('cancel'); 76 $this->xmlPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 77 $this->mockResponse->expectNever('write'); 78 $this->showLastXMLPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 77 79 } 78 80 79 81 /** 80 82 * assure that if all requirements are met the processor is executed … … 84 86 $this->mockRequest->setReturnValue('hasValue', true); 85 87 $this->mockSession->setReturnValue('isNew', false); 88 $this->mockSession->setReturnValue('getValue', 'foo'); 86 89 $this->mockRequest->expectOnce('cancel'); 87 $this->xmlPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 90 $this->mockResponse->expect('write', array('foo')); 91 $this->showLastXMLPreInterceptor->preProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 92 } 93 94 /** 95 * assure that postProcess() puts correct data into session 96 * 97 */ 98 public function testPostProcess() 99 { 100 $this->mockResponse->setReturnValue('getData', 'foo'); 101 $this->mockSession->expect('putValue', array(stubShowLastXMLInterceptor::SESSION_KEY, 'foo')); 102 $this->showLastXMLPreInterceptor->postProcess($this->mockRequest, $this->mockSession, $this->mockResponse); 88 103 } 89 104 }
