Skip to content

Commit 9696f5a

Browse files
committed
Merge branch 'release/0.8.8'
2 parents 431a7d8 + 41c2a86 commit 9696f5a

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"strategy": "semver",
33
"major": 0,
44
"minor": 8,
5-
"patch": 7,
5+
"patch": 8,
66
"build": 0
77
}

src/Mvc/Application.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,19 @@ protected function loadRoutes(): void
323323
throw new Validation( $exception->getMessage(), [] );
324324
}
325325

326-
foreach( $Data[ 'routes' ] as $Route )
326+
foreach( $Data[ 'routes' ] as $RouteName => $Route )
327327
{
328328
$Request = $Route[ 'request' ] ?? '';
329329
$Filter = $Route[ 'filter' ] ?? '';
330330

331-
$this->addRoute(
331+
$RouteMap = $this->addRoute(
332332
$Route[ 'method' ],
333333
$Route[ 'route' ],
334334
$Route[ 'controller' ],
335335
$Request,
336336
$Filter
337337
);
338+
$RouteMap->setName( $RouteName );
338339
}
339340
}
340341

tests/Mvc/ApplicationTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,31 @@ public function testMissingControllerMethod()
397397

398398
$this->assertTrue( $this->App->getCrashed() );
399399
}
400+
401+
/**
402+
* Test that route names are loaded from YAML and set on RouteMap objects
403+
*/
404+
public function testRouteNamesLoadedFromYaml()
405+
{
406+
$Router = $this->App->getRouter();
407+
408+
// Test that we can retrieve a route by its name from YAML
409+
$LoginRoute = $Router->getRouteByName( 'login' );
410+
411+
$this->assertNotNull( $LoginRoute, 'Route "login" should be found by name' );
412+
$this->assertEquals( '/login', $LoginRoute->Path, 'Route path should match' );
413+
$this->assertEquals( 'login', $LoginRoute->Name, 'Route name should be set' );
414+
415+
// Test another named route
416+
$TestRoute = $Router->getRouteByName( 'test' );
417+
418+
$this->assertNotNull( $TestRoute, 'Route "test" should be found by name' );
419+
$this->assertEquals( '/test', $TestRoute->Path, 'Test route path should match' );
420+
$this->assertEquals( 'test', $TestRoute->Name, 'Test route name should be set' );
421+
422+
// Test that a non-existent route returns null
423+
$NonExistentRoute = $Router->getRouteByName( 'nonexistent' );
424+
425+
$this->assertNull( $NonExistentRoute, 'Non-existent route should return null' );
426+
}
400427
}

versionlog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.8.8 2025-11-11
2+
* Fixed named routes.
3+
14
## 0.8.7 2025-11-10
25
* Updated error handling.
36

0 commit comments

Comments
 (0)