Skip to content

Commit 83040b3

Browse files
committed
test fix
1 parent aa6895c commit 83040b3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/Feature/ExportPostmanTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public function test_uri_is_correct()
330330
$this->assertEquals($targetRequest['request']['url']['raw'], '{{base_url}}/example/phpDocRoute');
331331
}
332332

333-
public function test_api_resource_routes_set_parameters_correctly()
333+
public function test_api_resource_routes_set_parameters_correctly_with_hyphens()
334334
{
335335
$this->artisan('export:postman')->assertExitCode(0);
336336

@@ -345,6 +345,21 @@ public function test_api_resource_routes_set_parameters_correctly()
345345
$this->assertEquals($targetRequest['request']['url']['raw'], '{{base_url}}/example/users/:user/audit-logs/:audit_log');
346346
}
347347

348+
public function test_api_resource_routes_set_parameters_correctly_with_underscores()
349+
{
350+
$this->artisan('export:postman')->assertExitCode(0);
351+
352+
$collection = collect(json_decode(Storage::get('postman/'.config('api-postman.filename')), true)['item']);
353+
354+
$targetRequest = $collection
355+
->where('name', 'example/users/{user}/other_logs/{other_log}')
356+
->where('request.method', 'PATCH')
357+
->first();
358+
359+
$this->assertEquals($targetRequest['name'], 'example/users/{user}/other_logs/{other_log}');
360+
$this->assertEquals($targetRequest['request']['url']['raw'], '{{base_url}}/example/users/:user/other_logs/:other_log');
361+
}
362+
348363
public static function providerFormDataEnabled(): array
349364
{
350365
return [
@@ -359,7 +374,7 @@ public static function providerFormDataEnabled(): array
359374

360375
private function countCollectionItems(array $collectionItems)
361376
{
362-
$sum = -1;
377+
$sum = -2;
363378

364379
foreach ($collectionItems as $item) {
365380
$sum += $this->retrieveRoutes($item);

tests/TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected function defineRoutes($router)
2424
$router->get('getWithFormRequest', [ExampleController::class, 'getWithFormRequest'])->name('get-with-form-request');
2525
$router->get('phpDocRoute', [ExampleController::class, 'phpDocRoute'])->name('php-doc-route');
2626
$router->apiResource('users.audit-logs', AuditLogController::class);
27+
$router->apiResource('users.other_logs', AuditLogController::class);
2728
});
2829
}
2930
}

0 commit comments

Comments
 (0)