Changeset 790
- Timestamp:
- 08/09/07 15:36:12 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/response/stubDecoratedResponse.php (added)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLResponse.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/response/stubDecoratedResponseTestCase.php (added)
- trunk/src/test/php/net/stubbles/websites/xml/stubXMLResponseTestCase.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/xml/stubXMLResponse.php
r292 r790 7 7 * @subpackage websites_xml 8 8 */ 9 stubClassLoader::load('net.stubbles.ipo.response.stub Response',9 stubClassLoader::load('net.stubbles.ipo.response.stubDecoratedResponse', 10 10 'net.stubbles.websites.stubPage' 11 11 ); … … 18 18 * @subpackage websites_xml 19 19 */ 20 class stubXMLResponse extends stub BaseObject implements stubResponse20 class stubXMLResponse extends stubDecoratedResponse 21 21 { 22 /**23 * the real response24 *25 * @var stubResponse26 */27 protected $response;28 22 /** 29 23 * the page where this response is created or … … 32 26 */ 33 27 protected $page = null; 34 35 /** 36 * constructor 37 * 38 * @param stubResponse $response 39 */ 40 public function __construct(stubResponse $response) 41 { 42 $this->response = $response; 43 } 44 28 45 29 /** 46 30 * sets the page where this response is created for … … 68 52 public function clear() 69 53 { 70 $this->response->clear();54 parent::clear(); 71 55 $this->page = null; 72 }73 74 /**75 * add a header to the response76 *77 * @param string $name the name of the header78 * @param string $value the value of the header79 */80 public function addHeader($name, $value)81 {82 $this->response->addHeader($name, $value);83 }84 85 /**86 * returns the list of headers87 *88 * @return array<string,string>89 */90 public function getHeaders()91 {92 return $this->response->getHeaders();93 }94 95 /**96 * add a cookie to the response97 *98 * @param stubCookie $cookie the cookie to set99 */100 public function setCookie(stubCookie $cookie)101 {102 $this->response->setCookie($cookie);103 }104 105 /**106 * returns the list of cookies107 *108 * @return array<stubCookie>109 */110 public function getCookies()111 {112 return $this->response->getCookies();113 }114 115 /**116 * write data into the response117 *118 * @param string $data119 */120 public function write($data)121 {122 $this->response->write($data);123 }124 125 /**126 * returns the data written so far127 *128 * @return string129 */130 public function getData()131 {132 return $this->response->getData();133 }134 135 /**136 * replaces the data written so far with the new data137 *138 * @param string $data139 */140 public function replaceData($data)141 {142 $this->response->replaceData($data);143 }144 145 /**146 * send the response out147 */148 public function send()149 {150 $this->response->send();151 56 } 152 57 } trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php
r731 r790 49 49 50 50 $this->addTestFile($dir . '/response/stubCookieTestCase.php'); 51 $this->addTestFile($dir . '/response/stubDecoratedResponseTestCase.php'); 51 52 52 53 $this->addTestFile($dir . '/session/stubAbstractSessionTestCase.php'); trunk/src/test/php/net/stubbles/websites/xml/stubXMLResponseTestCase.php
r292 r790 1 1 <?php 2 2 /** 3 * Tests for net.stubbles.websites.xml.stubXMLResponse 3 * Tests for net.stubbles.websites.xml.stubXMLResponse. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 10 10 Mock::generate('stubResponse'); 11 11 /** 12 * Tests for net.stubbles.websites.xml.stubXMLResponse 12 * Tests for net.stubbles.websites.xml.stubXMLResponse. 13 13 * 14 14 * @package stubbles … … 29 29 */ 30 30 protected $mockResponse; 31 31 32 32 /** 33 33 * set up test environment … … 38 38 $this->xmlResponse = new stubXMLResponse($this->mockResponse); 39 39 } 40 40 41 41 /** 42 42 * assure that page is handled correct … … 49 49 $page2 = $this->xmlResponse->getPage(); 50 50 $this->assertEqual($page2, $page); 51 }52 53 /**54 * assure that all methods of the decorated response are called correct55 */56 public function testPassthru()57 {58 $this->mockResponse->expectOnce('clear');59 $this->mockResponse->expectOnce('addHeader', array('name', 'value'));60 $this->mockResponse->expectOnce('getHeaders');61 $this->mockResponse->setReturnValue('getHeaders', array('name' => 'value'));62 $cookie = stubCookie::create('name', 'value');63 $this->mockResponse->expectOnce('setCookie', array($cookie));64 $this->mockResponse->expectOnce('getCookies');65 $this->mockResponse->setReturnValue('getCookies', array('name' => $cookie));66 $this->mockResponse->expectOnce('write', array('data'));67 $this->mockResponse->expectOnce('getData');68 $this->mockResponse->setReturnValue('getData', 'data');69 $this->mockResponse->expectOnce('replaceData', array('data'));70 $this->mockResponse->expectOnce('send');71 51 $this->xmlResponse->clear(); 72 $this->xmlResponse->addHeader('name', 'value'); 73 $this->assertEqual($this->xmlResponse->getHeaders(), array('name' => 'value')); 74 $this->xmlResponse->setCookie($cookie); 75 $this->assertEqual($this->xmlResponse->getCookies(), array('name' => $cookie)); 76 $this->xmlResponse->write('data'); 77 $this->assertEqual($this->xmlResponse->getData(), 'data'); 78 $this->xmlResponse->replaceData('data'); 79 $this->xmlResponse->send(); 52 $this->assertNull($this->xmlResponse->getPage()); 80 53 } 81 54 }
