Skip to content

Commit

Permalink
Extra tests for the router
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Feb 27, 2024
1 parent 037be4f commit 1352d30
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/apis/RoutingTestClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace app\apis;

use webfiori\http\Response;

class RoutingTestClass {
public function __construct(string $param = null, string $second = null) {
Response::write("I'm inside the class.");
}
public function doSomething() {
Response::clear();
Response::write("I'm doing something.");
}
public function doSomethingExtra(string $p1 = null, string $p2 = null) {
Response::clear();
Response::write("I'm doing something.");
}
}
29 changes: 29 additions & 0 deletions tests/webfiori/framework/test/router/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,33 @@ public function testSitemap05() {
. '</url>'
. '</urlset>', Response::getBody());
}
/**
* @test
*/
public function testClassRoute00() {
Response::clear();
Router::addRoute([
RouteOption::PATH => 'home',
RouteOption::TO => \app\apis\RoutingTestClass::class
]);
Router::route('https://127.0.0.1/home');

$this->assertEquals("I'm inside the class.", Response::getBody());
}
/**
* @test
*/
public function testClassRoute02() {
Response::clear();
Router::removeAll();
Router::addRoute([
RouteOption::PATH => 'home',
RouteOption::TO => \app\apis\RoutingTestClass::class,
RouteOption::ACTION => 'doSomething'
]);
Router::route('https://127.0.0.1/home');

$this->assertEquals("I'm doing something.", Response::getBody());
}

}

0 comments on commit 1352d30

Please sign in to comment.