summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/BasicStrategyTest.php12
-rw-r--r--tests/Unit/PathSegmentMatchTest.php2
-rw-r--r--tests/Unit/RouteCallTest.php2
-rw-r--r--tests/Unit/RouteTest.php3
-rw-r--r--tests/Unit/RouterTest.php14
-rw-r--r--tests/Utils/TestCall.php3
-rw-r--r--tests/Utils/TestCallable.php1
7 files changed, 18 insertions, 19 deletions
diff --git a/tests/Unit/BasicStrategyTest.php b/tests/Unit/BasicStrategyTest.php
index 2a0b550..1f1489a 100644
--- a/tests/Unit/BasicStrategyTest.php
+++ b/tests/Unit/BasicStrategyTest.php
@@ -9,12 +9,12 @@ use Lightscale\Router\Test\Utils\TestCallable;
use Nyholm\Psr7\Factory\Psr17Factory;
it('initialises')
- ->expect(fn() => new BasicStrategy)
+ ->expect(fn () => new BasicStrategy())
->toBeInstanceOf(BasicStrategy::class);
-it('throws on not found', function() {
- (new BasicStrategy)->notFound(
- (new Psr17Factory)->createServerRequest(
+it('throws on not found', function () {
+ (new BasicStrategy())->notFound(
+ (new Psr17Factory())->createServerRequest(
HttpMethod::Get->value,
'/testing/testing'
)
@@ -22,10 +22,10 @@ it('throws on not found', function() {
})->throws(NotFoundException::class);
it('calls route', function () {
- $factory = new Psr17Factory;
+ $factory = new Psr17Factory();
$response = $factory->createResponse(200, 'OK');
$cb = TestCallable::make(fn () => $response);
- $res = (new BasicStrategy)->runRoute($rc = new RouteCall(
+ $res = (new BasicStrategy())->runRoute($rc = new RouteCall(
$factory->createServerRequest(
HttpMethod::Get->value,
'/testing/testing'
diff --git a/tests/Unit/PathSegmentMatchTest.php b/tests/Unit/PathSegmentMatchTest.php
index 9a522a4..3059f26 100644
--- a/tests/Unit/PathSegmentMatchTest.php
+++ b/tests/Unit/PathSegmentMatchTest.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
use Lightscale\Router\PathSegment;
use Lightscale\Router\PathSegmentMatch;
-it('initializes with segment and params', function() {
+it('initializes with segment and params', function () {
$match = new PathSegmentMatch(
$seg = new PathSegment('testing'),
$params = ['test1' => 'test2'],
diff --git a/tests/Unit/RouteCallTest.php b/tests/Unit/RouteCallTest.php
index 70cc50e..ece0b91 100644
--- a/tests/Unit/RouteCallTest.php
+++ b/tests/Unit/RouteCallTest.php
@@ -8,7 +8,7 @@ use Lightscale\Router\RouteCall;
use Nyholm\Psr7\Factory\Psr17Factory;
it('initializes with data', function () {
- $factory = new Psr17Factory;
+ $factory = new Psr17Factory();
$call = new RouteCall(
request: $req = $factory->createServerRequest(HttpMethod::Get->value, '/test/test'),
route: $route = new Route(HttpMethod::Get, fn () => null),
diff --git a/tests/Unit/RouteTest.php b/tests/Unit/RouteTest.php
index 50513a1..e4ce06d 100644
--- a/tests/Unit/RouteTest.php
+++ b/tests/Unit/RouteTest.php
@@ -6,7 +6,6 @@ use Lightscale\Router\Enums\HttpMethod;
use Lightscale\Router\Enums\PathSegmentType;
use Lightscale\Router\PathSegment;
use Lightscale\Router\Route;
-use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Message\RequestInterface;
it('initializes')
@@ -47,7 +46,7 @@ it('gets method')
))->getMethod())
->toBe(HttpMethod::Get);
-it('can get handler', function() {
+it('can get handler', function () {
$r = new Route(
HttpMethod::Get,
$h = fn (RequestInterface $req) => $req->getUri()->getPath()
diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php
index 12e27a4..421cc7c 100644
--- a/tests/Unit/RouterTest.php
+++ b/tests/Unit/RouterTest.php
@@ -17,12 +17,12 @@ it('initializes')
->toBeInstanceOf(Router::class);
it('initializes with basic strategy')
- ->expect((new Router)->getStrategy())
+ ->expect((new Router())->getStrategy())
->toBeInstanceOf(BasicStrategy::class);
-it('can set strategy', function() {
- $router = new Router;
- $s = new BasicStrategy;
+it('can set strategy', function () {
+ $router = new Router();
+ $s = new BasicStrategy();
expect($router->getStrategy())->not->toBe($s);
$router->setStrategy($s);
expect($router->getStrategy())->toBe($s);
@@ -109,7 +109,7 @@ it('return null when segment not found', function () {
it('calls strategy notFound with dispatch', function () {
$router = new Router();
- $factory = new Psr17Factory;
+ $factory = new Psr17Factory();
$request = $factory->createServerRequest(HttpMethod::Get->value, '/testing/testing');
$response = $factory->createResponse();
@@ -123,7 +123,7 @@ it('calls strategy notFound with dispatch', function () {
expect($result)->toBe($response);
});
-it('calls strategy runRoute with dispatch on match', function() {
+it('calls strategy runRoute with dispatch on match', function () {
$router = new Router();
$router->root()->child('testing')->addRoute(new Route(
@@ -131,7 +131,7 @@ it('calls strategy runRoute with dispatch on match', function() {
fn () => null,
));
- $factory = new Psr17Factory;
+ $factory = new Psr17Factory();
$request = $factory->createServerRequest(HttpMethod::Get->value, '/testing');
$response = $factory->createResponse();
diff --git a/tests/Utils/TestCall.php b/tests/Utils/TestCall.php
index 971e6a7..3b9a2f3 100644
--- a/tests/Utils/TestCall.php
+++ b/tests/Utils/TestCall.php
@@ -12,5 +12,6 @@ readonly class TestCall
public function __construct(
public array $args,
public mixed $return,
- ){}
+ ) {
+ }
}
diff --git a/tests/Utils/TestCallable.php b/tests/Utils/TestCallable.php
index 42a3bb5..526ddf4 100644
--- a/tests/Utils/TestCallable.php
+++ b/tests/Utils/TestCallable.php
@@ -65,5 +65,4 @@ class TestCallable
{
Assert::assertSame($amount, $this->getCallCount());
}
-
}