Skip to content

Commit

Permalink
fix: dynamic url doesn't mind which order assemblies are in
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Nov 28, 2021
1 parent 5bad687 commit 757c2f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Path/DynamicPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getUrl(string $viewBasePath):string {
continue;
}

break;
break(2);
}
}

Expand Down
17 changes: 13 additions & 4 deletions test/phpunit/Path/DynamicPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,25 @@ public function testGet_noKey_shouldReturnDeepest():void {
}

public function testGetUrl():void {
$assembly = self::createMock(Assembly::class);
$assembly->method("current")
$viewAssembly = self::createMock(Assembly::class);
$viewAssembly->method("current")
->willReturnOnConsecutiveCalls(
"page/_header.html",
"page/_footer.html",
"page/shop/@category/@itemName.html",
);
$assembly->method("valid")
$viewAssembly->method("valid")
->willReturn(true);
$sut = new DynamicPath("/shop/OnePlus/6T", $assembly);
$logicAssembly = self::createMock(Assembly::class);
$logicAssembly->method("current")
->willReturnOnConsecutiveCalls(
"page/_common.php",
"page/shop/_common.php",
"page/shop/@category/@itemName.php",
);
$logicAssembly->method("valid")
->willReturn(true);
$sut = new DynamicPath("/shop/OnePlus/6T", $viewAssembly, $logicAssembly);
self::assertSame("/shop/@category/@itemName", $sut->getUrl("page/"));
}
}

0 comments on commit 757c2f3

Please sign in to comment.