Changeset 1425

Show
Ignore:
Timestamp:
03/14/08 17:09:12 (6 months ago)
Author:
mikey
Message:

change skin generator to take the page directly as argument instead throughout the response container

Files:

Legend:

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

    r1424 r1425  
    88 */ 
    99stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     10                      'net::stubbles::ipo::session::stubSession', 
    1011                      'net::stubbles::lang::exceptions::stubRuntimeException', 
    1112                      'net::stubbles::util::stubFactory', 
    1213                      'net::stubbles::util::stubRegistry', 
     14                      'net::stubbles::websites::stubPage', 
    1315                      'net::stubbles::xml::stubXMLXIncludeStreamWrapper', 
    1416                      'net::stubbles::xml::stubXMLStreamWriterFactory', 
     
    5759     * generates the skin document 
    5860     * 
    59      * @param   stubSession      $session 
    60      * @param   stubXMLResponse  $respons
     61     * @param   stubSession  $session 
     62     * @param   stubPage     $pag
    6163     * @return  DOMDocument 
    6264     * @throws  stubRuntimeException 
    6365     */ 
    64     public function generate(stubSession $session, stubXMLResponse $response) 
     66    public function generate(stubSession $session, stubPage $page) 
    6567    { 
    6668        $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
     
    7880         
    7981        $xslProcessor->importXSLStylesheet($this->createXSLStylesheet()); 
    80         $page = $response->getPage(); 
    8182        $xslProcessor->setParameter('', 'page', $page->getProperty('name')); 
    8283        if ($session->hasValue('net.stubbles.language') == true) { 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r1424 r1425  
    8888        $this->response->setXMLStreamWriter($xmlStreamWriter); 
    8989        $xslProcessor = $this->createXSLProcessor(); 
    90         $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $this->response)); 
     90        $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $page)); 
    9191        $xslProcessor->setXMLDocument($xmlStreamWriter->asDOM()); 
    9292        $this->response->replaceData(str_replace(' xmlns=""', '', preg_replace('/ xml:base="(.*)"/U', '', $xslProcessor->transformToXML()))); 
  • trunk/src/test/php/net/stubbles/websites/xml/skin/stubSkinGeneratorTestCase.php

    r1424 r1425  
    4141    protected $skinGenerator; 
    4242    /** 
    43      * instance to be used for tests 
    44      * 
    45      * @var  stubXMLResponse 
    46      */ 
    47     protected $xmlResponse; 
    48     /** 
    49      * mocked response instance 
    50      * 
    51      * @var  PHPUnit_Framework_MockObject_MockObject 
    52      */ 
    53     protected $mockResponse; 
    54     /** 
    5543     * the page instance 
    5644     * 
     
    10088                                              ) 
    10189                               ); 
    102         $this->mockResponse  = $this->getMock('stubResponse'); 
    103         $this->xmlResponse   = new stubXMLResponse($this->mockResponse); 
    104         $this->page          = new stubPage(); 
    105         $this->xmlResponse->setPage($this->page); 
    10690        $this->mockSession       = $this->getMock('stubSession'); 
     91        $this->page              = new stubPage(); 
    10792        $this->mockXSLProcessor  = $this->getMock('stubXSLProcessor'); 
    10893        $this->resultDomDocument = new DOMDocument(); 
     
    127112 
    128113    /** 
    129      * assure that a correct response works as expected 
    130      * 
    131      * @test 
    132      */ 
    133     public function correctResponse() 
     114     * assure that callbacks are registered 
     115     * 
     116     * @test 
     117     */ 
     118    public function withCallbacks() 
    134119    { 
    135120        $this->page->setProperty('name', 'baz'); 
     
    145130        $this->mockXSLProcessor->expects($this->once())->method('registerCallback')->with($this->equalTo('foo'), $this->equalTo($callback)); 
    146131 
    147         $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->xmlResponse)); 
     132        $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 
    148133    } 
    149134 
     
    161146                            ->with($this->equalTo('another')) 
    162147                            ->will($this->returnValue($this->getMock('DOMDocument'))); 
    163         $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->xmlResponse)); 
     148        $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 
    164149    } 
    165150 
     
    177162                            ->will($this->returnValue($this->getMock('DOMDocument'))); 
    178163        $this->mockXSLProcessor->expects($this->at(2))->method('setParameter')->with($this->equalTo(''), $this->equalTo('lang'), $this->equalTo('foo')); 
    179         $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->xmlResponse)); 
     164        $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 
    180165    } 
    181166 
     
    194179                            ->will($this->returnValue($this->getMock('DOMDocument'))); 
    195180        $this->mockXSLProcessor->expects($this->at(2))->method('setParameter')->with($this->equalTo(''), $this->equalTo('lang'), $this->equalTo('bar')); 
    196         $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->xmlResponse)); 
     181        $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 
    197182    } 
    198183 
     
    213198        stubRegistry::setConfig('net.stubbles.language', 'foo'); 
    214199        $this->mockXSLProcessor->expects($this->at(2))->method('setParameter')->with($this->equalTo(''), $this->equalTo('lang'), $this->equalTo('baz')); 
    215         $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->xmlResponse)); 
     200        $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 
    216201    } 
    217202 
     
    225210    { 
    226211        stubRegistry::remove(stubBinder::REGISTRY_KEY); 
    227         $this->skinGenerator->generate($this->mockSession, $this->xmlResponse); 
     212        $this->skinGenerator->generate($this->mockSession, $this->page); 
    228213    } 
    229214