public function testDirectAccess() { $app = new WebApplication(__DIR__ . "/app", "/testpage"); ob_start(); $app->run(); ob_end_clean(); $this->assertInstanceOf("Pages\\Testpage", $app->getLoops()->getService("web_core")->page); }
function testPath() { $app = new WebApplication(__DIR__ . "/app", "/"); ob_start(); $app->run(); ob_end_clean(); $errorpage = new ErrorPage(404, $app->getLoops()); $this->assertEquals("", $errorpage->getPagePath()); $app = new WebApplication(__DIR__ . "/app", "/test"); ob_start(); $app->run(); ob_end_clean(); $errorpage = new ErrorPage(404, $app->getLoops()); $this->assertEquals("test", $errorpage->getPagePath()); $app = new WebApplication(__DIR__ . "/app", "/test/longerurl"); ob_start(); $app->run(); ob_end_clean(); $errorpage = new ErrorPage(404, $app->getLoops()); $this->assertEquals("test/longerurl", $errorpage->getPagePath()); }
<?php /** * This file is part of the loops framework. * * @author Lukas <*****@*****.**> * @license https://raw.githubusercontent.com/loopsframework/base/master/LICENSE * @link https://github.com/loopsframework/base */ use Loops\Misc; use Loops\Application\WebApplication; try { $root_dir = realpath(__DIR__ . "/.."); require_once "{$root_dir}/vendor/autoload.php"; $url = $_GET["_url"]; unset($_GET["_url"]); $app = new WebApplication("{$root_dir}/app/", $url); $app->run(); } catch (Exception $e) { Misc::displayException($e); }