Skip to content

Commit

Permalink
Fix bug that makes crud try to render random segments
Browse files Browse the repository at this point in the history
  • Loading branch information
nmeri17 committed Apr 24, 2023
1 parent c19df3f commit 8970dd2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Routing/RouteManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ private function extractRenderer (RouteCollection $collection, string $remainder

$methodName = $this->findActiveCrud(array_keys($possibleRenderers), $remainder);

if (!array_key_exists($methodName, $possibleRenderers)) // invalid path or segment received for a crud path

return null;

$renderer = $possibleRenderers[$methodName];
}

Expand Down
20 changes: 20 additions & 0 deletions tests/Integration/Routing/Crud/GenericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,25 @@ public function test_override_non_existent_throws_error () {

$this->fakeRequest("/non-existent/save"); // when
}

/**
* @dataProvider invalidCruds
*/
public function test_correctly_fails_invalid_paths (string $requestPath) {

$matchingRenderer = $this->fakeRequest("/save-all/$requestPath"); // when

$this->assertNull($matchingRenderer); // then // means 404
}

public function invalidCruds ():array {

return [

["/create"], // extra slash

["create/nmeri"]
];
}
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create

0 comments on commit 8970dd2

Please sign in to comment.