Example #1
0
 public function testCmsExceptionPhp()
 {
     $theme = Theme::load('test');
     $router = new Router($theme);
     $page = $router->findByUrl('/throw-php');
     $foreignException = new \Symfony\Component\Debug\Exception\FatalErrorException('This is a general error', 100, 1, 'test.php', 20);
     $this->setProtectedProperty($foreignException, 'file', "/modules/cms/classes/CodeParser.php(165) : eval()'d code line 7");
     $exception = new CmsException($page, 300);
     $exception->setMask($foreignException);
     $this->assertEquals($page->getFilePath(), $exception->getFile());
     $this->assertEquals('PHP Content', $exception->getErrorType());
     $this->assertEquals('This is a general error', $exception->getMessage());
 }
Example #2
0
 /**
  * Looks up an error page using the CMS route "/error". If the route does not
  * exist, this function will use the error view found in the Cms module.
  * @return mixed Error page contents.
  */
 public function handleCustomError()
 {
     if (Config::get('app.debug', false)) {
         return null;
     }
     $theme = Theme::getActiveTheme();
     // Use the default view if no "/error" URL is found.
     $router = new Router($theme);
     if (!$router->findByUrl('/error')) {
         return View::make('cms::error');
     }
     // Route to the CMS error page.
     $controller = new Controller($theme);
     return $controller->run('/error');
 }
Example #3
0
 /**
  * Looks up an error page using the CMS route "/error". If the route does not
  * exist, this function will use the error view found in the Cms module.
  * @return mixed Error page contents.
  */
 public function handleCustomError()
 {
     if (Config::get('app.debug', false)) {
         return null;
     }
     $theme = Theme::getActiveTheme();
     // Use the default view if no "/error" URL is found.
     $router = new Router($theme);
     if (!$router->findByUrl('/error')) {
         return View::make('cms::error');
     }
     // Route to the CMS error page.
     $controller = new Controller($theme);
     $result = $controller->run('/error');
     // Extract content from response object
     if ($result instanceof \Symfony\Component\HttpFoundation\Response) {
         $result = $result->getContent();
     }
     return $result;
 }
Example #4
0
 public function testFindPageFromSubdirectory()
 {
     $router = new Router(self::$theme);
     $page = $router->findByUrl('/apage');
     $this->assertNotEmpty($page);
     $this->assertEquals('a/a-page.htm', $page->getFileName());
     $page = $router->findByUrl('/bpage');
     $this->assertNotEmpty($page);
     $this->assertEquals('b/b-page.htm', $page->getFileName());
 }