From 5c6f36e2b39b125eeea0bd4b4704ec3c99abae31 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 18 Aug 2024 00:12:57 +0400 Subject: [PATCH] Add immutability tests (#18) --- tests/FileRouterTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/FileRouterTest.php b/tests/FileRouterTest.php index bb4fef2..3257814 100644 --- a/tests/FileRouterTest.php +++ b/tests/FileRouterTest.php @@ -391,6 +391,17 @@ public function testModularityFastPath(): void $router->process($request, $handler); } + public function testImmutability(): void + { + $router = $this->createRouter(); + + $this->assertNotSame($router, $router->withBaseControllerDirectory('x')); + $this->assertNotSame($router, $router->withClassPostfix('x')); + $this->assertNotSame($router, $router->withNamespace('x')); + $this->assertNotSame($router, $router->withDefaultControllerName('x')); + $this->assertNotSame($router, $router->withRoutePrefix('x')); + } + private function createRouter(): FileRouter { $container = new SimpleContainer([