Пример #1
0
 public function setUp()
 {
     $_SERVER = array('REQUEST_URI' => '/index/index/param1/1/?param2=2');
     $this->request = $this->getMockRequest();
     $this->application = new \Rapid\Application(__DIR__ . '/../../../application/', 'development');
     $this->application->addModule('admin/');
     $this->router = new \Rapid\Router($this->application, $this->request);
 }
Пример #2
0
 protected function processPath()
 {
     $path = $this->request->path();
     $parts = explode('/', $path);
     $partsCount = count($parts);
     $partsMaxIndex = $partsCount - 1;
     $module = '';
     $controller = '';
     $action = '';
     $paramsKey = '';
     foreach ($parts as $key => $part) {
         if (!$controller && $this->application->hasModule($module . $part . '/')) {
             $module .= $part . '/';
             continue;
         }
         if (!$controller) {
             $controller = $part;
             continue;
         }
         if (!$action) {
             $action = $part;
             continue;
         }
         if ($partsMaxIndex > $key && !$paramsKey) {
             $paramsKey = $part;
             continue;
         }
         if ($paramsKey) {
             $this->request->setParam($paramsKey, $part);
             $paramsKey = '';
         } else {
             $this->request->setParam($part, 1);
         }
     }
     $this->request->setModule($module)->setController($controller ? $controller : $this->defaultController)->setAction($action ? $action : $this->defaultAction);
 }
Пример #3
0
 protected function layoutFile($name)
 {
     $layoutsPath = $this->application->layoutPath();
     $name = strpos($name, '.phtml') === false ? $name . '.phtml' : $name;
     return $layoutsPath . $name;
 }
Пример #4
0
 public function testPath()
 {
     $this->assertEquals($this->appPath, $this->app->path(), 'Paths are not equal');
 }