Changeset 790

Show
Ignore:
Timestamp:
08/09/07 15:36:12 (1 year ago)
Author:
mikey
Message:

splitted general decorating from net.stubbles.websites.xml.stubXMLResponse to net.stubbles.ipo.response.stubDecoratedResponse

Files:

Legend:

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

    r292 r790  
    77 * @subpackage  websites_xml 
    88 */ 
    9 stubClassLoader::load('net.stubbles.ipo.response.stubResponse', 
     9stubClassLoader::load('net.stubbles.ipo.response.stubDecoratedResponse', 
    1010                      'net.stubbles.websites.stubPage' 
    1111); 
     
    1818 * @subpackage  websites_xml 
    1919 */ 
    20 class stubXMLResponse extends stubBaseObject implements stubResponse 
     20class stubXMLResponse extends stubDecoratedResponse 
    2121{ 
    22     /** 
    23      * the real response 
    24      * 
    25      * @var  stubResponse 
    26      */ 
    27     protected $response; 
    2822    /** 
    2923     * the page where this response is created or 
     
    3226     */ 
    3327    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 
    4529    /** 
    4630     * sets the page where this response is created for 
     
    6852    public function clear() 
    6953    { 
    70         $this->response->clear(); 
     54        parent::clear(); 
    7155        $this->page = null; 
    72     } 
    73      
    74     /** 
    75      * add a header to the response 
    76      * 
    77      * @param  string  $name   the name of the header 
    78      * @param  string  $value  the value of the header 
    79      */ 
    80     public function addHeader($name, $value) 
    81     { 
    82         $this->response->addHeader($name, $value); 
    83     } 
    84      
    85     /** 
    86      * returns the list of headers 
    87      * 
    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 response 
    97      * 
    98      * @param  stubCookie  $cookie  the cookie to set 
    99      */ 
    100     public function setCookie(stubCookie $cookie) 
    101     { 
    102         $this->response->setCookie($cookie); 
    103     } 
    104      
    105     /** 
    106      * returns the list of cookies 
    107      * 
    108      * @return  array<stubCookie> 
    109      */ 
    110     public function getCookies() 
    111     { 
    112         return $this->response->getCookies(); 
    113     } 
    114      
    115     /** 
    116      * write data into the response 
    117      * 
    118      * @param  string  $data 
    119      */ 
    120     public function write($data) 
    121     { 
    122         $this->response->write($data); 
    123     } 
    124      
    125     /** 
    126      * returns the data written so far 
    127      *  
    128      * @return  string 
    129      */ 
    130     public function getData() 
    131     { 
    132         return $this->response->getData(); 
    133     } 
    134      
    135     /** 
    136      * replaces the data written so far with the new data 
    137      * 
    138      * @param  string  $data 
    139      */ 
    140     public function replaceData($data) 
    141     { 
    142         $this->response->replaceData($data); 
    143     } 
    144      
    145     /** 
    146      * send the response out 
    147      */ 
    148     public function send() 
    149     { 
    150         $this->response->send(); 
    15156    } 
    15257} 
  • trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php

    r731 r790  
    4949         
    5050        $this->addTestFile($dir . '/response/stubCookieTestCase.php'); 
     51        $this->addTestFile($dir . '/response/stubDecoratedResponseTestCase.php'); 
    5152         
    5253        $this->addTestFile($dir . '/session/stubAbstractSessionTestCase.php'); 
  • trunk/src/test/php/net/stubbles/websites/xml/stubXMLResponseTestCase.php

    r292 r790  
    11<?php 
    22/** 
    3  * Tests for net.stubbles.websites.xml.stubXMLResponse 
     3 * Tests for net.stubbles.websites.xml.stubXMLResponse. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    1010Mock::generate('stubResponse'); 
    1111/** 
    12  * Tests for net.stubbles.websites.xml.stubXMLResponse 
     12 * Tests for net.stubbles.websites.xml.stubXMLResponse. 
    1313 * 
    1414 * @package     stubbles 
     
    2929     */ 
    3030    protected $mockResponse; 
    31      
     31 
    3232    /** 
    3333     * set up test environment 
     
    3838        $this->xmlResponse  = new stubXMLResponse($this->mockResponse); 
    3939    } 
    40      
     40 
    4141    /** 
    4242     * assure that page is handled correct 
     
    4949        $page2 = $this->xmlResponse->getPage(); 
    5050        $this->assertEqual($page2, $page); 
    51     } 
    52      
    53     /** 
    54      * assure that all methods of the decorated response are called correct 
    55      */ 
    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'); 
    7151        $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()); 
    8053    } 
    8154}