Skip to content

Commit

Permalink
Merge pull request #99 from andreaselia/fix/incorrect-uri
Browse files Browse the repository at this point in the history
add test case to catch uri naming
  • Loading branch information
andreaselia authored Apr 2, 2024
2 parents dd797eb + daeafda commit 9a83411
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/Processors/RouteProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ protected function processRoute(Route $route)
$routeHeaders[] = $this->authentication->toArray();
}

$uri = Str::of($route->uri())
->after('/')
->replaceMatches('/{([[:alnum:]]+)}/', ':$1');
$uri = Str::of($route->uri())->replaceMatches('/{([[:alnum:]]+)}/', ':$1');

// if (!$uri->toString()) {
// return [];
Expand Down
16 changes: 14 additions & 2 deletions tests/Feature/ExportPostmanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ public function test_php_doc_comment_export()

$this->artisan('export:postman')->assertExitCode(0);

$this->assertTrue(true);

$collection = collect(json_decode(Storage::get('postman/'.config('api-postman.filename')), true)['item']);

$targetRequest = $collection
Expand All @@ -277,6 +275,20 @@ public function test_php_doc_comment_export()
$this->assertEquals($targetRequest['request']['description'], 'This is the php doc route. Which is also multi-line. and has a blank line.');
}

public function test_uri_is_correct()
{
$this->artisan('export:postman')->assertExitCode(0);

$collection = collect(json_decode(Storage::get('postman/'.config('api-postman.filename')), true)['item']);

$targetRequest = $collection
->where('name', 'example/phpDocRoute')
->first();

$this->assertEquals($targetRequest['name'], 'example/phpDocRoute');
$this->assertEquals($targetRequest['request']['url']['raw'], '{{base_url}}/example/phpDocRoute');
}

public static function providerFormDataEnabled(): array
{
return [
Expand Down

0 comments on commit 9a83411

Please sign in to comment.