Changeset 1442

Show
Ignore:
Timestamp:
03/20/08 00:15:23 (2 months ago)
Author:
mikey
Message:

refactoring #137, part 5: replaced stubAbstractPageProcessor by interface stubPageBasedProcessor

Files:

Legend:

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

    r1355 r1442  
    1414                      'net::stubbles::util::validators::stubPreSelectValidator', 
    1515                      'net::stubbles::websites::cache::stubCachableProcessor', 
    16                       'net::stubbles::websites::processors::stubAbstractPageProcessor', 
     16                      'net::stubbles::websites::processors::stubAbstractProcessor', 
     17                      'net::stubbles::websites::processors::stubPageBasedProcessor', 
    1718                      'net::stubbles::websites::memphis::stubMemphisConfig', 
    1819                      'net::stubbles::websites::memphis::stubMemphisTemplate' 
     
    2425 * @subpackage  websites_memphis 
    2526 */ 
    26 class stubMemphisProcessor extends stubAbstractPageProcessor implements stubCachableProcessor 
     27class stubMemphisProcessor extends stubAbstractProcessor implements stubCachableProcessor, stubPageBasedProcessor 
    2728{ 
    2829    /** 
     
    4445     */ 
    4546    protected $cache; 
     47    /** 
     48     * page to display 
     49     * 
     50     * @var  stubPage 
     51     */ 
     52    protected $page; 
     53    /** 
     54     * name of page to display 
     55     * 
     56     * @var  string 
     57     */ 
     58    protected $pageName; 
    4659 
    4760    /** 
    4861     * constructor 
    4962     * 
    50      * @param   stubRequest      $request      the current request 
    51      * @param   stubSession      $session      the current session 
    52      * @param   stubResponse     $response     the current response 
    53      * @param   stubPageFactory  $pageFactory  page factory to use to read the page configuration 
    54      * @throws  stubException 
    55      */ 
    56     public function __construct(stubRequest $request, stubSession $session, stubResponse $response, stubPageFactory $pageFactory) 
    57     { 
    58         parent::__construct($request, $session, $response, $pageFactory); 
    59         $this->config   = $this->createConfig(); 
     63     * @param  stubRequest   $request   the current request 
     64     * @param  stubSession   $session   the current session 
     65     * @param  stubResponse  $response  the current response 
     66     */ 
     67    public function __construct(stubRequest $request, stubSession $session, stubResponse $response) 
     68    { 
     69        parent::__construct($request, $session, $response); 
     70        $this->config = $this->createConfig(); 
    6071    } 
    6172 
     
    6879    { 
    6980        $this->cache = $websiteCache; 
     81    } 
     82 
     83    /** 
     84     * selects the page to display with help of the page factory 
     85     * 
     86     * @param  stubPageFactory  $pageFactory 
     87     */ 
     88    public function selectPage(stubPageFactory $pageFactory) 
     89    { 
     90        $this->pageName = $pageFactory->getPageName($this->request); 
     91        $this->page     = $pageFactory->getPage($this->pageName); 
     92        $this->session->putValue('net.stubbles.websites.lastPage', $this->pageName); 
    7093    } 
    7194 
     
    97120 
    98121    /** 
    99      * does the real processing 
    100      * 
    101      * @param  stubPage  $page      the page to process 
    102      * @param  string    $pageName  name of the page to process 
    103      */ 
    104     protected function doProcess(stubPage $page, $pageName) 
    105     { 
    106         $elements      = $page->getElements(); 
     122     * processes the request 
     123     */ 
     124    public function process() 
     125    { 
     126        $elements      = $this->page->getElements(); 
    107127        $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); 
    108128        $context       = array('part' => null, 
    109                                'page' => $page 
     129                               'page' => $this->page 
    110130                         ); 
    111         $frameId       = $this->getFrameId($page); 
     131        $frameId       = $this->getFrameId(); 
    112132        if (null !== $this->cache) { 
    113             $cachable = $this->processCacheVars($prefixRequest, $elements, $pageName, $frameId, $context); 
    114             if (true === $cachable && $this->cache->retrieve($this->request, $this->session, $this->response, $pageName) === true) { 
     133            $cachable = $this->processCacheVars($prefixRequest, $elements, $frameId, $context); 
     134            if (true === $cachable && $this->cache->retrieve($this->request, $this->session, $this->response, $this->pageName) === true) { 
    115135                return; 
    116136            } 
     
    120140        $context['template'] = $this->template; 
    121141        $this->template->readTemplatesFromInput($this->config->getFrame($frameId)); 
    122         $this->setTemplateVars($page, $pageName, $frameId); 
     142        $this->setTemplateVars($frameId); 
    123143        $this->processPageElements($prefixRequest, $elements, $context); 
    124144        if (null !== $this->cache) { 
    125145            if (true === $cachable) { 
    126                 $this->cache->store($this->request, $this->response, $pageName); 
     146                $this->cache->store($this->request, $this->response, $this->pageName); 
    127147            } 
    128148 
     
    138158     * @param   stubRequest  $prefixRequest 
    139159     * @param   array        $elements 
    140      * @param   string       $pageName 
    141160     * @param   string       $frameId 
    142161     * @param   array        $context 
    143162     * @return  bool         true if page is cachable, else false 
    144163     */ 
    145     protected function processCacheVars(stubRequest $prefixRequest, array $elements, $pageName, $frameId, array $context) 
    146     { 
    147         $this->cache->addCacheVar('page', $pageName); 
     164    protected function processCacheVars(stubRequest $prefixRequest, array $elements, $frameId, array $context) 
     165    { 
     166        $this->cache->addCacheVar('page', $this->pageName); 
    148167        $this->cache->addCacheVar('frame', $frameId); 
    149168        $this->cache->addCacheVar('variant', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
     
    233252     * helper method to get the name of the frame to use 
    234253     * 
    235      * @param   stubPage  $page 
    236254     * @return  string 
    237255     */ 
    238     protected function getFrameId(stubPage $page
    239     { 
    240         if ($page->hasProperty('frame_fixed') === true && $page->getProperty('frame_fixed') === true) { 
    241             return $page->getProperty('frame'); 
     256    protected function getFrameId(
     257    { 
     258        if ($this->page->hasProperty('frame_fixed') === true && $this->page->getProperty('frame_fixed') === true) { 
     259            return $this->page->getProperty('frame'); 
    242260        } 
    243261 
     
    247265            $frame = $this->session->getValue('net.stubbles.websites.memphis.frame'); 
    248266        } else { 
    249             $frame = $page->getProperty('frame'); 
     267            $frame = $this->page->getProperty('frame'); 
    250268        } 
    251269 
     
    260278     * helper method to set the template vars 
    261279     * 
    262      * @param  stubPage  $page 
    263      * @param  string    $pageName 
    264280     * @param  string    $frameId 
    265281     */ 
    266     protected function setTemplateVars(stubPage $page, $pageName, $frameId) 
     282    protected function setTemplateVars($frameId) 
    267283    { 
    268284        $this->template->addGlobalVar('UCUO_FRAME', $frameId); 
    269         $this->template->addGlobalVar('PAGE_TITLE', htmlentities($page->getProperty('title'))); 
    270         $this->template->addGlobalVar('PAGE_NAME', $pageName); 
     285        $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->page->getProperty('title'))); 
     286        $this->template->addGlobalVar('PAGE_NAME', $this->pageName); 
    271287        $this->template->addGlobalVar('VARIANT', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
    272288        $this->template->addGlobalVar('VARIANT_ALIAS', $this->session->getValue('net.stubbles.websites.variantmanager.variant.alias', '')); 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php

    r1441 r1442  
    3838    protected $response; 
    3939    /** 
    40      * the factory that creates the page instance 
    41      * 
    42      * @var  stubPageFactory 
    43      */ 
    44     protected $pageFactory; 
    45     /** 
    4640     * the interceptor descriptor 
    4741     * 
     
    5953     * constructor 
    6054     * 
    61      * @param  stubRequest      $request      the current request 
    62      * @param  stubSession      $session      the current session 
    63      * @param  stubResponse     $response     the current response 
    64      * @param  stubPageFactory  $pageFactory  page factory to use to read the page configuration 
     55     * @param  stubRequest   $request   the current request 
     56     * @param  stubSession   $session   the current session 
     57     * @param  stubResponse  $response  the current response 
    6558     */ 
    66     public function __construct(stubRequest $request, stubSession $session, stubResponse $response, stubPageFactory $pageFactory
     59    public function __construct(stubRequest $request, stubSession $session, stubResponse $response
    6760    { 
    68         $this->request     = $request; 
    69         $this->session     = $session; 
    70         $this->response    = $response; 
    71         $this->pageFactory = $pageFactory; 
     61        $this->request   = $request; 
     62        $this->session   = $session; 
     63        $this->response  = $response; 
    7264    } 
    7365 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessorResolver.php

    r1231 r1442  
    77 * @subpackage  websites_processors 
    88 */ 
    9 stubClassLoader::load('net::stubbles::websites::processors::stubProcessorResolver'); 
     9stubClassLoader::load('net::stubbles::websites::processors::stubPageBasedProcessor', 
     10                      'net::stubbles::websites::processors::stubProcessorResolver' 
     11); 
    1012/** 
    1113 * Basic abstract implementation of a processor resolver. 
     
    6163        stubClassLoader::load($processorClassName); 
    6264        $className = stubClassLoader::getNonQualifiedClassName($processorClassName); 
    63         $processor = new $className($request, $session, $response, $this->pageFactory); 
     65        $processor = new $className($request, $session, $response); 
    6466        if (($processor instanceof stubProcessor) == false) { 
    6567            throw new stubProcessorException($processorClassName . ' is not an instance of ' . stubClassLoader::getFullQualifiedClassName('stubProcessor')); 
     
    6769         
    6870        $this->configureInterceptorDescriptor($processor); 
     71         
     72        if ($processor instanceof stubPageBasedProcessor) { 
     73            $processor->selectPage($this->pageFactory); 
     74        } 
     75         
    6976        return $processor; 
    7077    } 
  • trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusProcessor.php

    r1248 r1442  
    77 * @subpackage  websites_rasmus 
    88 */ 
    9 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractPageProcessor'); 
     9stubClassLoader::load('net::stubbles::websites::processors::stubAbstractProcessor', 
     10                      'net::stubbles::websites::processors::stubPageBasedProcessor' 
     11); 
    1012/** 
    1113 * Processor for rasmus pages. 
     
    1416 * @subpackage  websites_rasmus 
    1517 */ 
    16 class stubRasmusProcessor extends stubAbstractPageProcessor 
     18class stubRasmusProcessor extends stubAbstractProcessor implements stubPageBasedProcessor 
    1719{ 
    1820    /** 
    19      * does the real processing 
     21     * page to display 
    2022     * 
    21      * @param  stubPage  $page      the page to process 
    22      * @param  string    $pageName  name of the page to process 
     23     * @var  stubPage 
    2324     */ 
    24     protected function doProcess(stubPage $page, $pageName) 
     25    protected $page; 
     26 
     27    /** 
     28     * selects the page to display with help of the page factory 
     29     * 
     30     * @param  stubPageFactory  $pageFactory 
     31     */ 
     32    public function selectPage(stubPageFactory $pageFactory) 
    2533    { 
    26         $page->render($this->request, $this->session, $this->response); 
     34        $this->page = $pageFactory->getPage($pageFactory->getPageName($this->request)); 
     35    } 
     36 
     37    /** 
     38     * processes the request 
     39     */ 
     40    public function process() 
     41    { 
     42        $this->page->render($this->request, $this->session, $this->response); 
    2743        $this->response->addHeader('X-Generator', 'Rasmus\' Template Engine :-) powered by Stubbles, http://stubbles.net/'); 
    2844    } 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r1431 r1442  
    1111                      'net::stubbles::lang::exceptions::stubRuntimeException', 
    1212                      'net::stubbles::util::stubRegistry', 
    13                       'net::stubbles::websites::processors::stubAbstractPageProcessor', 
     13                      'net::stubbles::websites::processors::stubAbstractProcessor', 
     14                      'net::stubbles::websites::processors::stubPageBasedProcessor', 
    1415                      'net::stubbles::websites::xml::skin::stubSkinGeneratorFactory', 
    1516                      'net::stubbles::xml::stubXMLStreamWriterFactory', 
     
    2223 * @subpackage  websites_xml 
    2324 */ 
    24 class stubXMLProcessor extends stubAbstractPageProcessor 
     25class stubXMLProcessor extends stubAbstractProcessor implements stubPageBasedProcessor 
    2526{ 
    2627    /** 
     
    3031     */ 
    3132    protected $xmlGenerators = array(); 
     33    /** 
     34     * page to display 
     35     * 
     36     * @var  stubPage 
     37     */ 
     38    protected $page; 
     39    /** 
     40     * name of page to display 
     41     * 
     42     * @var  string 
     43     */ 
     44    protected $pageName; 
    3245 
    3346    /** 
    3447     * constructor 
    3548     * 
    36      * @param  stubRequest      $request      the current request 
    37      * @param  stubSession      $session      the current session 
    38      * @param  stubResponse     $response     the current response 
    39      * @param  stubPageFactory  $pageFactory  page factory to use to read the page configuration 
     49     * @param  stubRequest   $request   the current request 
     50     * @param  stubSession   $session   the current session 
     51     * @param  stubResponse  $response  the current response 
    4052     */ 
    41     public function __construct(stubRequest $request, stubSession $session, stubResponse $response, stubPageFactory $pageFactory
     53    public function __construct(stubRequest $request, stubSession $session, stubResponse $response
    4254    { 
    43         parent::__construct($request, $session, $response, $pageFactory); 
    44         $this->pageDirPrefix = 'conf/'; 
     55        parent::__construct($request, $session, $response); 
    4556        $this->configureXMLGenerators(); 
    4657    } 
     
    5869 
    5970    /** 
    60      * does the real processing 
     71     * selects the page to display with help of the page factory 
    6172     * 
    62      * @param   stubPage  $page      the page to process 
    63      * @param   string    $pageName  name of the page to process 
    64      * @throws  stubRuntimeException 
     73     * @param  stubPageFactory  $pageFactory 
    6574     */ 
    66     protected function doProcess(stubPage $page, $pageName) 
     75    public function selectPage(stubPageFactory $pageFactory) 
     76    { 
     77        $pageFactory->setPagePrefix('conf/'); 
     78        $this->pageName = $pageFactory->getPageName($this->request); 
     79        $this->page     = $pageFactory->getPage($this->pageName); 
     80        $this->session->putValue('net.stubbles.websites.lastPage', $this->pageName); 
     81    } 
     82 
     83    /** 
     84     * processes the request 
     85     */ 
     86    public function process() 
    6787    { 
    6888        $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
     
    7191        } 
    7292         
    73         $binder->bind('stubPage')->toInstance($page); 
     93        $binder->bind('stubPage')->toInstance($this->page); 
    7494        $injector        = $binder->getInjector(); 
    7595        $xmlStreamWriter = $this->createXMLStreamWriter(); 
    7696        $xmlStreamWriter->writeStartElement('document'); 
    77         $xmlStreamWriter->writeAttribute('page', $pageName); 
     97        $xmlStreamWriter->writeAttribute('page', $this->pageName); 
    7898        $xmlSerializer = $this->createXMLSerializer(); 
    7999        foreach ($this->xmlGenerators as $xmlGeneratorClassName) { 
     
    84104        $xmlStreamWriter->writeEndElement(); // end document 
    85105        $xslProcessor = $this->createXSLProcessor(); 
    86         $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $page)); 
     106        $xslProcessor->importXSLStylesheet($this->createSkinGenerator()->generate($this->session, $this->page)); 
    87107        $xslProcessor->setXMLDocument($xmlStreamWriter->asDOM()); 
    88108        $this->session->putValue('net.stubbles.websites.lastRequestResponseData', $xmlStreamWriter->asXML()); 
  • trunk/src/main/php/org/stubbles/test/FooProcessor.php

    r1248 r1442  
    3838        return $this->response; 
    3939    } 
    40  
    41     public function getPageFactory() 
    42     { 
    43         return $this->pageFactory; 
    44     } 
    4540} 
    4641?> 
  • trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php

    r1355 r1442  
    119119     * @param   stubRequest  $prefixRequest 
    120120     * @param   array        $elements 
    121      * @param   string       $pageName 
    122121     * @param   string       $frameId 
    123122     * @param   array        $context 
    124123     * @return  bool 
    125124     */ 
    126     public function callProcessCacheVars(stubRequest $prefixRequest, array $elements, $pageName, $frameId, array $context) 
    127     { 
    128         return $this->processCacheVars($prefixRequest, $elements, $pageName, $frameId, $context); 
     125    public function callProcessCacheVars(stubRequest $prefixRequest, array $elements, $frameId, array $context) 
     126    { 
     127        return $this->processCacheVars($prefixRequest, $elements, $frameId, $context); 
    129128    } 
    130129 
     
    144143     * helper method to access protected method getFrameId() 
    145144     * 
    146      * @param   stubPage  $page 
    147145     * @return  string 
    148146     */ 
    149     public function callGetFrameId(stubPage $page
    150     { 
    151         return $this->getFrameId($page); 
     147    public function callGetFrameId(
     148    { 
     149        return $this->getFrameId(); 
    152150    } 
    153151    /** 
    154152     * helper method to access protected method setTemplateVars() 
    155153     * 
    156      * @param  stubPage  $page 
    157      * @param  string    $pageName 
    158154     * @param  string    $frameId 
    159155     */ 
    160     public function callSetTemplateVars(stubPage $page, $pageName, $frameId) 
    161     { 
    162         return $this->setTemplateVars($page, $pageName, $frameId); 
     156    public function callSetTemplateVars($frameId) 
     157    { 
     158        return $this->setTemplateVars($frameId); 
    163159    } 
    164160} 
     
    174170     * constructor 
    175171     * 
    176      * @param   stubRequest      $request      the current request 
    177      * @param   stubSession      $session      the current session 
    178      * @param   stubResponse     $response     the current response 
    179      * @param   stubPageFactory  $pageFactory  page factory to use to read the page configuration 
    180      */ 
    181     public function __construct(stubRequest $request, stubSession $session, stubResponse $response, stubPageFactory $pageFactory) 
     172     * @param  stubRequest   $request   the current request 
     173     * @param  stubSession   $session   the current session 
     174     * @param  stubResponse  $response  the current response 
     175     */ 
     176    public function __construct(stubRequest $request, stubSession $session, stubResponse $response) 
    182177    { 
    183178        $this->request     = $request; 
    184179        $this->session     = $session; 
    185180        $this->response    = $response; 
    186         $this->pageFactory = $pageFactory; 
    187181    } 
    188182 
     
    195189    { 
    196190        $this->config = $config; 
    197     } 
    198  
    199     /** 
    200      * helper method to call protected method doProcess() 
    201      */ 
    202     public function callDoProcess($page, $pageName) 
    203     { 
    204         $this->doProcess($page, $pageName); 
    205191    } 
    206192} 
     
    274260        $this->mockResponse      = $this->getMock('stubResponse'); 
    275261        $this->mockPageFactory   = $this->getMock('stubPageFactory'); 
    276         $this->memphisProcessor  = new TeststubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse, $this->mockPageFactory); 
     262        $this->memphisProcessor  = new TeststubMemphisProcessor($this->mockRequest, $this->mockSession, $this->mockResponse); 
    277263        $this->mockMemphisConfig = $this->getMock('TeststubMemphisConfig'); 
    278264        $this->memphisProcessor->setConfig($this->mockMemphisConfig); 
     
    280266        $this->memphisProcessor->setTemplate($this->mockMemphisTemplate); 
    281267        $this->mockPage = $this->getMock('stubPage'); 
     268        $this->mockPageFactory->expects($this->any())->method('getPageName')->will($this->returnValue('index')); 
    282269        $this->mockPageFactory->expects($this->any())->method('getPage')->will($this->returnValue($this->mockPage)); 
     270        $this->memphisProcessor->selectPage($this->mockPageFactory); 
    283271    } 
    284272 
     
    292280        $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 
    293281                                           array('createTemplate', 
    294                                                  'getPageName', 
    295282                                                 'getFrameId', 
    296283                                                 'processCacheVars', 
     
    300287                                           array($this->mockRequest, 
    301288                                                 $this->mockSession, 
    302                                                  $this->mockResponse, 
    303                                                  $this->mockPageFactory 
     289                                                 $this->mockResponse 
    304290                                           ) 
    305291                            ); 
    306292        $memphisProcessor->setConfig($this->mockMemphisConfig); 
     293        $memphisProcessor->selectPage($this->mockPageFactory); 
     294         
    307295        $memphisProcessor->expects($this->once())->method('createTemplate')->will($this->returnValue($this->mockMemphisTemplate)); 
    308         $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 
    309296        $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 
    310297        $mockPageElement = $this->getMock('stubPageElement'); 
     
    317304        $this->mockResponse->expects($this->never())->method('getData'); 
    318305        $this->mockResponse->expects($this->never())->method('replaceData'); 
    319         $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 
     306        $memphisProcessor->process(); 
    320307    } 
    321308 
     
    329316        $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 
    330317                                           array('createTemplate', 
    331                                                  'getPageName', 
    332318                                                 'getFrameId', 
    333319                                                 'processCacheVars', 
     
    337323                                           array($this->mockRequest, 
    338324                                                 $this->mockSession, 
    339                                                  $this->mockResponse, 
    340                                                  $this->mockPageFactory 
     325                                                 $this->mockResponse 
    341326                                           ) 
    342327                            ); 
    343328        $memphisProcessor->setConfig($this->mockMemphisConfig); 
     329        $memphisProcessor->selectPage($this->mockPageFactory); 
     330         
    344331        $memphisProcessor->expects($this->once())->method('createTemplate')->will($this->returnValue($this->mockMemphisTemplate)); 
    345         $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 
    346332        $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 
    347333        $mockPageElement = $this->getMock('stubPageElement'); 
     
    351337                         ->with($this->anything(), 
    352338                                $this->equalTo(array('baz' => $mockPageElement)), 
    353                                 $this->equalTo('foo'), 
    354339                                $this->equalTo('bar')) 
    355340                         ->will($this->returnValue(true)); 
     
    363348                         $this->equalTo($this->mockSession), 
    364349                         $this->equalTo($this->mockResponse), 
    365                          $this->equalTo('foo')) 
     350                         $this->equalTo('index')) 
    366351                  ->will($this->returnValue(false)); 
    367352        $mockCache->expects($this->once()) 
     
    369354                  ->with($this->equalTo($this->mockRequest), 
    370355                         $this->equalTo($this->mockResponse), 
    371                          $this->equalTo('foo')); 
     356                         $this->equalTo('index')); 
    372357        $memphisProcessor->setWebsiteCache($mockCache); 
    373358        $this->mockResponse->expects($this->once())->method('getData')->will($this->returnValue('$SID$SESSION_NAME$SESSION_ID')); 
     
    375360        $this->mockSession->expects($this->any())->method('getName')->will($this->returnValue('name')); 
    376361        $this->mockResponse->expects($this->once())->method('replaceData')->with($this->equalTo('name=idnameid')); 
    377         $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 
     362        $memphisProcessor->process(); 
    378363    } 
    379364 
     
    387372        $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 
    388373                                           array('createTemplate', 
    389                                                  'getPageName', 
    390374                                                 'getFrameId', 
    391375                                                 'processCacheVars', 
     
    395379                                           array($this->mockRequest, 
    396380                                                 $this->mockSession, 
    397                                                  $this->mockResponse, 
    398                                                  $this->mockPageFactory 
     381                                                 $this->mockResponse 
    399382                                           ) 
    400383                            ); 
    401384        $memphisProcessor->setConfig($this->mockMemphisConfig); 
     385        $memphisProcessor->selectPage($this->mockPageFactory); 
     386         
    402387        $memphisProcessor->expects($this->once())->method('createTemplate')->will($this->returnValue($this->mockMemphisTemplate)); 
    403         $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 
    404388        $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 
    405389        $mockPageElement = $this->getMock('stubPageElement'); 
     
    409393                         ->with($this->anything(), 
    410394                                $this->equalTo(array('baz' => $mockPageElement)), 
    411                                 $this->equalTo('foo'), 
    412395                                $this->equalTo('bar')) 
    413396                         ->will($this->returnValue(false)); 
     
    423406        $this->mockSession->expects($this->any())->method('getName')->will($this->returnValue('name')); 
    424407        $this->mockResponse->expects($this->once())->method('replaceData')->with($this->equalTo('name=idnameid')); 
    425         $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 
     408        $memphisProcessor->process(); 
    426409    } 
    427410 
     
    435418        $memphisProcessor = $this->getMock('Test2stubMemphisProcessor', 
    436419                                           array('createTemplate', 
    437                                                  'getPageName', 
    438420                                                 'getFrameId', 
    439421                                                 'processCacheVars', 
     
    443425                                           array($this->mockRequest, 
    444426                                                 $this->mockSession, 
    445                                                  $this->mockResponse, 
    446                                                  $this->mockPageFactory 
     427                                                 $this->mockResponse 
    447428                                           ) 
    448429                            ); 
    449430        $memphisProcessor->setConfig($this->mockMemphisConfig); 
     431        $memphisProcessor->selectPage($this->mockPageFactory); 
     432         
    450433        $memphisProcessor->expects($this->never())->method('createTemplate'); 
    451         $memphisProcessor->expects($this->any())->method('getPageName')->will($this->returnValue('foo')); 
    452434        $memphisProcessor->expects($this->any())->method('getFrameId')->will($this->returnValue('bar')); 
    453435        $mockPageElement = $this->getMock('stubPageElement'); 
     
    457439                         ->with($this->anything(), 
    458440                                $this->equalTo(array('baz' => $mockPageElement)), 
    459                                 $this->equalTo('foo'), 
    460441                                $this->equalTo('bar')) 
    461442                         ->will($this->returnValue(true)); 
     
    470451                         $this->equalTo($this->mockSession), 
    471452                         $this->equalTo($this->mockResponse), 
    472                          $this->equalTo('foo')) 
     453                         $this->equalTo('index')) 
    473454                  ->will($this->returnValue(true)); 
    474455        $mockCache->expects($this->never())->method('store'); 
     
    476457        $this->mockResponse->expects($this->never())->method('getData'); 
    477458        $this->mockResponse->expects($this->never())->method('replaceData'); 
    478         $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 
     459        $memphisProcessor->process(); 
    479460    } 
    480461 
     
    515496        $mockCache = new stubDummyWebsiteCache(); 
    516497        $this->memphisProcessor->setWebsiteCache($mockCache); 
    517         $this->assertTrue($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 
    518         $this->assertEquals(array('page'    => 'foo', 
     498        $this->assertTrue($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'bar', array())); 
     499        $this->assertEquals(array('page'    => 'index', 
    519500                                  'frame'   => 'bar', 
    520501                                  'variant' => null, 
     
    568549        $mockCache = new stubDummyWebsiteCache(); 
    569550        $this->memphisProcessor->setWebsiteCache($mockCache); 
    570         $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 
    571         $this->assertEquals(array('page'    => 'foo', 
     551        $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'bar', array())); 
     552        $this->assertEquals(array('page'    => 'index', 
    572553                                  'frame'   => 'bar', 
    573554                                  'variant' => null, 
     
    621602        $this->memphisProcessor->setSSL(true); 
    622603        $this->memphisProcessor->setWebsiteCache($mockCache); 
    623         $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'foo', 'bar', array())); 
    624         $this->assertEquals(array('page'    => 'foo', 
     604        $this->assertFalse($this->memphisProcessor->callProcessCacheVars($prefixRequest, array('mock1' => $mockPageElement1, 'mock2' => $mockPageElement2), 'bar', array())); 
     605        $this->assertEquals(array('page'    => 'index', 
    625606                                  'frame'   => 'bar', 
    626607                                  'variant' => null, 
     
    752733        $this->mockMemphisConfig->expects($this->any())->method('getFrames')->will($this->returnValue(array('default'))); 
    753734        $page = new stubPage(); 
     735        $mockPageFactory = $this->getMock('stubPageFactory'); 
     736        $mockPageFactory->expects($this->once())->method('getPageName')->will($this->returnValue('index')); 
     737        $mockPageFactory->expects($this->once())->method('getPage')->will($this->returnValue($page)); 
     738        $this->memphisProcessor->selectPage($mockPageFactory); 
    754739        $this->mockRequest->expects($this->any())->method('hasValue')->will($this->returnValue(true)); 
    755740        $this->mockRequest->expects($this->exactly(3)) 
     
    757742                          ->will($this->onConsecutiveCalls('another', '', null)); 
    758743        $this->mockSession->expects($this->never())->method('hasValue'); 
    759         $this->assertEquals('another', $this->memphisProcessor->callGetFrameId($page)); 
    760         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
    761         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
     744        $this->assertEquals('another', $this->memphisProcessor->callGetFrameId()); 
     745        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
     746        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
    762747    } 
    763748 
     
    770755    { 
    771756        $page = new stubPage(); 
     757        $mockPageFactory = $this->getMock('stubPageFactory'); 
     758        $mockPageFactory->expects($this->once())->method('getPageName')->will($this->returnValue('index')); 
     759        $mockPageFactory->expects($this->once())->method('getPage')->will($this->returnValue($page)); 
     760        $this->memphisProcessor->selectPage($mockPageFactory); 
    772761        $this->mockRequest->expects($this->any())->method('hasValue')->will($this->returnValue(false)); 
    773762        $this->mockRequest->expects($this->never())->method('getValidatedValue'); 
     
    776765                          ->method('getValue') 
    777766                          ->will($this->onConsecutiveCalls('another', '', null)); 
    778         $this->assertEquals('another', $this->memphisProcessor->callGetFrameId($page)); 
    779         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
    780         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
     767        $this->assertEquals('another', $this->memphisProcessor->callGetFrameId()); 
     768        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
     769        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
    781770    } 
    782771 
     
    789778    { 
    790779        $page = new stubPage(); 
     780        $mockPageFactory = $this->getMock('stubPageFactory'); 
     781        $mockPageFactory->expects($this->once())->method('getPageName')->will($this->returnValue('index')); 
     782        $mockPageFactory->expects($this->once())->method('getPage')->will($this->returnValue($page)); 
     783        $this->memphisProcessor->selectPage($mockPageFactory); 
    791784        $this->mockRequest->expects($this->any())->method('hasValue')->will($this->returnValue(false)); 
    792785        $this->mockRequest->expects($this->never())->method('getValidatedValue'); 
    793786        $this->mockSession->expects($this->any())->method('hasValue')->will($this->returnValue(false)); 
    794787        $this->mockSession->expects($this->never())->method('getValue'); 
    795         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
     788        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
    796789        $page->setProperty('frame', ''); 
    797         $this->assertEquals('default', $this->memphisProcessor->callGetFrameId($page)); 
     790        $this->assertEquals('default', $this->memphisProcessor->callGetFrameId()); 
    798791        $page->setProperty('frame', 'another'); 
    799         $this->assertEquals('another', $this->memphisProcessor->callGetFrameId($page)); 
     792        $this->assertEquals('another', $this->memphisProcessor->callGetFrameId()); 
    800793    } 
    801794 
     
    810803        $page->setProperty('frame', '404'); 
    811804        $page->setProperty('frame_fixed', true); 
     805        $mockPageFactory = $this->getMock('stubPageFactory'); 
     806        $mockPageFactory->expects($this->once())->method('getPageName')->will($this->returnValue('index')); 
     807        $mockPageFactory->expects($this->once())->method('getPage')->will($this->returnValue($page)); 
     808        $this->memphisProcessor->selectPage($mockPageFactory); 
    812809        $this->mockRequest->expects($this->any())->method('hasValue'); 
    813810        $this->mockSession->expects($this->any())->method('hasValue'); 
    814         $this->assertEquals('404', $this->memphisProcessor->callGetFrameId($page)); 
     811        $this->assertEquals('404', $this->memphisProcessor->callGetFrameId()); 
    815812    } 
    816813 
     
    822819    public function setTemplateVars1() 
    823820    { 
     821        $this->mockPage->expects($this->once())->method('getProperty')->will($this->returnValue('bar')); 
    824822        $this->mockMemphisConfig->expects($this->any()) 
    825823                                ->method('getMetaTags') 
     
    835833        $this->mockMemphisTemplate->expects($this->at(2)) 
    836834                                  ->method('addGlobalVar')