diff --git a/tests/webfiori/framework/test/router/RouterTest.php b/tests/webfiori/framework/test/router/RouterTest.php
index 1300defe..c3f2b417 100644
--- a/tests/webfiori/framework/test/router/RouterTest.php
+++ b/tests/webfiori/framework/test/router/RouterTest.php
@@ -283,10 +283,214 @@ public function testRedirect01() {
*/
public function testRedirect03() {
Response::removeHeader('location');
- Router::redirect('home', 'https://google.com', 3099);
+ Router::redirect('home/{id}', 'https://google.com', 3099);
+ Router::route('https://127.0.0.1/home/55');
+ $this->assertEquals(301, Response::getCode());
+ $locHeader = Response::getHeader('location');
+ $this->assertEquals(['https://google.com'], $locHeader);
+ $this->assertEquals(55, Router::getParameterValue('id'));
+ $this->assertTrue(Router::removeRoute('home/{id}'));
+ }
+ /**
+ * @test
+ */
+ public function testRedirect04() {
+ Response::setCode(404);
+ Response::removeHeader('location');
+ Router::removeAll();
+ Router::redirect('home/{id?}', 'https://google.com', 400);
Router::route('https://127.0.0.1/home');
$this->assertEquals(301, Response::getCode());
$locHeader = Response::getHeader('location');
$this->assertEquals(['https://google.com'], $locHeader);
+ $this->assertNull(Router::getParameterValue('id'));
+ $this->assertTrue(Router::removeRoute('home/{id?}'));
+ }
+ /**
+ * @test
+ */
+ public function testSitemap00() {
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Response::clear();
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . '', Response::getBody());
+ }
+ /**
+ * @test
+ */
+ public function testSitemap01() {
+ Response::clear();
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Router::closure([
+ RouteOption::PATH => 'home',
+ RouteOption::TO => function () {
+
+ },
+ RouteOption::SITEMAP => true
+ ]);
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . ''
+ . 'https://127.0.0.1/home'
+ . ''
+ . '', Response::getBody());
+ }
+ /**
+ * @test
+ */
+ public function testSitemap02() {
+ Response::clear();
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Router::closure([
+ RouteOption::PATH => 'home/{id}',
+ RouteOption::TO => function () {
+
+ },
+ RouteOption::SITEMAP => true
+ ]);
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . '', Response::getBody());
+ }
+ /**
+ * @test
+ */
+ public function testSitemap03() {
+ Response::clear();
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Router::closure([
+ RouteOption::PATH => 'home/{id}',
+ RouteOption::TO => function () {
+
+ },
+ RouteOption::SITEMAP => true,
+ RouteOption::VALUES => [
+ 'id' => [1,2]
+ ]
+ ]);
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/1'
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/2'
+ . ''
+ . '', Response::getBody());
+ }
+ /**
+ * @test
+ */
+ public function testSitemap04() {
+ Response::clear();
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Router::closure([
+ RouteOption::PATH => 'home/{id}',
+ RouteOption::TO => function () {
+
+ },
+ RouteOption::SITEMAP => true,
+ RouteOption::VALUES => [
+ 'id' => [1,2]
+ ],
+ RouteOption::LANGS => ['en']
+ ]);
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/1'
+ . ''
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/2'
+ . ''
+ . ''
+ . '', Response::getBody());
+ }
+ /**
+ * @test
+ */
+ public function testSitemap05() {
+ Response::clear();
+ Router::removeAll();
+ Router::incSiteMapRoute();
+ Router::closure([
+ RouteOption::PATH => 'home/{id}',
+ RouteOption::TO => function () {
+
+ },
+ RouteOption::SITEMAP => true,
+ RouteOption::VALUES => [
+ 'id' => [1,2]
+ ],
+ RouteOption::LANGS => ['en', 'ar']
+ ]);
+ Router::route('https://127.0.0.1/sitemap');
+ $this->assertEquals(['text/xml'], Response::getHeader('content-type'));
+ $this->assertEquals(''
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap.xml'
+ . ''
+ . ''
+ . 'https://127.0.0.1/sitemap'
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/1'
+ . ''
+ . ''
+ . ''
+ . ''
+ . 'https://127.0.0.1/home/2'
+ . ''
+ . ''
+ . ''
+ . '', Response::getBody());
}
}