Skip to content

Commit 9a83411

Browse files
authored
Merge pull request #99 from andreaselia/fix/incorrect-uri
add test case to catch uri naming
2 parents dd797eb + daeafda commit 9a83411

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Processors/RouteProcessor.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ protected function processRoute(Route $route)
8484
$routeHeaders[] = $this->authentication->toArray();
8585
}
8686

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

9189
// if (!$uri->toString()) {
9290
// return [];

tests/Feature/ExportPostmanTest.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ public function test_php_doc_comment_export()
266266

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

269-
$this->assertTrue(true);
270-
271269
$collection = collect(json_decode(Storage::get('postman/'.config('api-postman.filename')), true)['item']);
272270

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

278+
public function test_uri_is_correct()
279+
{
280+
$this->artisan('export:postman')->assertExitCode(0);
281+
282+
$collection = collect(json_decode(Storage::get('postman/'.config('api-postman.filename')), true)['item']);
283+
284+
$targetRequest = $collection
285+
->where('name', 'example/phpDocRoute')
286+
->first();
287+
288+
$this->assertEquals($targetRequest['name'], 'example/phpDocRoute');
289+
$this->assertEquals($targetRequest['request']['url']['raw'], '{{base_url}}/example/phpDocRoute');
290+
}
291+
280292
public static function providerFormDataEnabled(): array
281293
{
282294
return [

0 commit comments

Comments
 (0)