Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jul 1, 2021
1 parent 697427d commit 4b59fb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function __invoke(ExtractedEndpointData $endpointData, array $routeRules)
$name = rtrim($match, '?');

// In case of /users/{user:id}, make the param {user}, but
$binding = $endpointData->route->bindingFieldFor($name);
$binding = null;
// Was added in Laravel 7.x
if (method_exists($endpointData->route, 'bindingFieldFor')) {
$binding = $endpointData->route->bindingFieldFor($name);
}
$parameters[$name] = [
'name' => $name,
'description' => $this->inferUrlParamDescription($endpointData->uri, $binding ?: $name, $binding ? $name : null),
Expand Down
6 changes: 6 additions & 0 deletions tests/Strategies/UrlParameters/GetFromLaravelAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public function __construct(array $parameters = [])
/** @test */
public function can_infer_data_from_field_bindings()
{
if (version_compare($this->app->version(), '7.0.0', '<')) {
$this->markTestSkipped("Laravel < 7.x doesn't support field binding syntax.");

return;
}

$strategy = new GetFromLaravelAPI(new DocumentationConfig([]));

$endpoint = new class extends ExtractedEndpointData {
Expand Down

0 comments on commit 4b59fb9

Please sign in to comment.