예제 #1
0
 public function testBasicGetRequest()
 {
     $o = new RwDispatcher();
     $oRequest = $o->getRequest();
     $oBlaReq = vsc::getEnv()->getHttpRequest();
     $this->assertSame($oRequest, $oBlaReq);
 }
예제 #2
0
 public function testGetMapsMap()
 {
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $o->loadSiteMap($sFixturePath . 'map.php');
     $this->assertInstanceOf(SiteMapA::class, $o->getSiteMap());
 }
 public function testBasicGetSitemap()
 {
     $o = new RwDispatcher();
     $o->loadSiteMap(VSC_FIXTURE_PATH . 'config/map.php');
     $map = $o->getCurrentProcessorMap();
     $this->assertInstanceOf(MappingA::class, $map);
     $this->assertInstanceOf(ClassMap::class, $map);
 }
예제 #4
0
 public function testGetProcessorController()
 {
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $o->loadSiteMap($sFixturePath . 'map.php');
     $oRequest = new PopulatedRequest();
     vsc::getEnv()->setHttpRequest($oRequest);
     $this->assertInstanceOf(ProcessorFixture::class, $o->getProcessController());
 }
예제 #5
0
 public function testTemplatePath()
 {
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $o->loadSiteMap($sFixturePath . 'map.php');
     $oRequest = new PopulatedRequest();
     vsc::getEnv()->setHttpRequest($oRequest);
     $genericTemplatePath = VSC_FIXTURE_PATH . 'templates' . DIRECTORY_SEPARATOR;
     $this->assertEquals($genericTemplatePath, $o->getTemplatePath());
 }
예제 #6
0
 public function testLoadSiteMap()
 {
     $Exception = new ExceptionError('test', 123);
     $o = new ErrorProcessor($Exception);
     $oMap = new ClassMap(ErrorProcessor::class, '.*');
     $o->setMap($oMap);
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $o->loadSiteMap($sFixturePath . 'map.php');
     $this->assertInstanceOf(SiteMapA::class, $o->getSiteMap());
 }
예제 #7
0
파일: mapTest.php 프로젝트: bogdananton/vsc
 public function testParentModuleMap()
 {
     vsc::getEnv()->getHttpRequest()->setUri('/');
     $o = new RwDispatcher();
     $this->assertTrue($o->loadSiteMap(VSC_RES_PATH . 'config/map.php'));
     $moduleMap = $o->getCurrentModuleMap();
     $this->assertInstanceOf(MappingA::class, $moduleMap);
     $this->assertInstanceOf(ModuleMap::class, $moduleMap);
     $this->assertEquals(VSC_RES_PATH . 'templates' . DIRECTORY_SEPARATOR, $moduleMap->getTemplatePath());
     $this->assertEquals(VSC_RES_PATH . 'templates' . DIRECTORY_SEPARATOR, $moduleMap->getMainTemplatePath());
     $this->assertEquals('main.php', $moduleMap->getMainTemplate());
 }
예제 #8
0
 public function testBasicGetFrontController()
 {
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $this->assertTrue(is_file($sFixturePath . 'map.php'));
     $this->assertTrue($o->loadSiteMap($sFixturePath . 'map.php'));
     $oRequest = new PopulatedRequest();
     vsc::getEnv()->setHttpRequest($oRequest);
     try {
         $oFront = $o->getFrontController();
         $this->assertInstanceOf(FrontControllerA::class, $oFront);
     } catch (\Exception $e) {
         $this->assertInstanceOf(ExceptionResponseError::class, $e);
     }
 }
예제 #9
0
    public function testCurrentMapWithInvalidRegex()
    {
        set_error_handler(function ($iSeverity, $sMessage, $sFilename, $iLineNo) {
            \vsc\exceptions_error_handler($iSeverity, $sMessage, $sFilename, $iLineNo);
        });
        $sRegex = '\\';
        $aMaps = array();
        $aMaps[$sRegex] = new ClassMap(EmptyProcessor::class, $sRegex);
        $o = new RwDispatcher();
        try {
            $o->getCurrentMap($aMaps);
        } catch (\ErrorException $err) {
            $errMessage = <<<START
preg_match_all(): No ending delimiter '#' found<br/> Offending regular expression: <span style="font-weight:normal">#\\#iu</span>
START;
            $this->assertInstanceOf(ExceptionError::class, $err);
            $this->assertEquals($errMessage, $err->getMessage());
        }
    }
예제 #10
0
 public function testUseless()
 {
     $o = new RwDispatcher();
     $this->assertEmpty($o->getView());
 }