Changeset 1425
- Timestamp:
- 03/14/08 17:09:12 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/xml/skin/stubSkinGenerator.php
r1424 r1425 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder', 10 'net::stubbles::ipo::session::stubSession', 10 11 'net::stubbles::lang::exceptions::stubRuntimeException', 11 12 'net::stubbles::util::stubFactory', 12 13 'net::stubbles::util::stubRegistry', 14 'net::stubbles::websites::stubPage', 13 15 'net::stubbles::xml::stubXMLXIncludeStreamWrapper', 14 16 'net::stubbles::xml::stubXMLStreamWriterFactory', … … 57 59 * generates the skin document 58 60 * 59 * @param stubSession $session60 * @param stub XMLResponse $response61 * @param stubSession $session 62 * @param stubPage $page 61 63 * @return DOMDocument 62 64 * @throws stubRuntimeException 63 65 */ 64 public function generate(stubSession $session, stub XMLResponse $response)66 public function generate(stubSession $session, stubPage $page) 65 67 { 66 68 $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); … … 78 80 79 81 $xslProcessor->importXSLStylesheet($this->createXSLStylesheet()); 80 $page = $response->getPage();81 82 $xslProcessor->setParameter('', 'page', $page->getProperty('name')); 82 83 if ($session->hasValue('net.stubbles.language') == true) { trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php
r1424 r1425 88 88 $this->response->setXMLStreamWriter($xmlStreamWriter); 89 89 $xslProcessor = $this->createXSLProcessor(); 90 $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $ this->response));90 $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $page)); 91 91 $xslProcessor->setXMLDocument($xmlStreamWriter->asDOM()); 92 92 $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 41 41 protected $skinGenerator; 42 42 /** 43 * instance to be used for tests44 *45 * @var stubXMLResponse46 */47 protected $xmlResponse;48 /**49 * mocked response instance50 *51 * @var PHPUnit_Framework_MockObject_MockObject52 */53 protected $mockResponse;54 /**55 43 * the page instance 56 44 * … … 100 88 ) 101 89 ); 102 $this->mockResponse = $this->getMock('stubResponse');103 $this->xmlResponse = new stubXMLResponse($this->mockResponse);104 $this->page = new stubPage();105 $this->xmlResponse->setPage($this->page);106 90 $this->mockSession = $this->getMock('stubSession'); 91 $this->page = new stubPage(); 107 92 $this->mockXSLProcessor = $this->getMock('stubXSLProcessor'); 108 93 $this->resultDomDocument = new DOMDocument(); … … 127 112 128 113 /** 129 * assure that a correct response works as expected130 * 131 * @test 132 */ 133 public function correctResponse()114 * assure that callbacks are registered 115 * 116 * @test 117 */ 118 public function withCallbacks() 134 119 { 135 120 $this->page->setProperty('name', 'baz'); … … 145 130 $this->mockXSLProcessor->expects($this->once())->method('registerCallback')->with($this->equalTo('foo'), $this->equalTo($callback)); 146 131 147 $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this-> xmlResponse));132 $this->assertSame($this->resultDomDocument, $this->skinGenerator->generate($this->mockSession, $this->page)); 148 133 } 149 134 … … 161 146 ->with($this->equalTo('another')) 162 147 ->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)); 164 149 } 165 150 … … 177 162 ->will($this->returnValue($this->getMock('DOMDocument'))); 178 163 $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)); 180 165 } 181 166 … … 194 179 ->will($this->returnValue($this->getMock('DOMDocument'))); 195 180 $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)); 197 182 } 198 183 … … 213 198 stubRegistry::setConfig('net.stubbles.language', 'foo'); 214 199 $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)); 216 201 } 217 202 … … 225 210 { 226 211 stubRegistry::remove(stubBinder::REGISTRY_KEY); 227 $this->skinGenerator->generate($this->mockSession, $this-> xmlResponse);212 $this->skinGenerator->generate($this->mockSession, $this->page); 228 213 } 229 214
