Skip to content

Commit

Permalink
Add failing test for underscore resource params
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jan 24, 2022
1 parent b6739fe commit 710dd8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<file>tests/Unit/ExtractorPluginSystemTest.php</file>
</testsuite>
<testsuite name="Unit Tests 2">
<file>tests/Unit/ExtractedEndpointDataTest.php</file>
<file>tests/Unit/AnnotationParserTest.php</file>
</testsuite>
<testsuite name="Unit Tests 3">
Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/ExtractedEndpointDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,26 @@ public function will_normalize_resource_url_params()
$this->assertEquals('things/{id}/otherthings/{otherthing_id}', $endpoint->uri);
}
}

/** @test */
public function will_normalize_resource_url_params_with_hyphens()
{
Route::apiResource('audio-things', TestController::class)
->only('show');
$routeRules[0]['match'] = ['prefixes' => '*', 'domains' => '*'];

$matcher = new RouteMatcher();
$matchedRoutes = $matcher->getRoutes($routeRules);

foreach ($matchedRoutes as $matchedRoute) {
$route = $matchedRoute->getRoute();
$this->assertEquals('audio-things/{audio_thing}', $route->uri);
$endpoint = new ExtractedEndpointData([
'route' => $route,
'uri' => $route->uri,
'httpMethods' => $route->methods,
]);
$this->assertEquals('audio-things/{id}', $endpoint->uri);
}
}
}

0 comments on commit 710dd8c

Please sign in to comment.