|
@@ -242,9 +242,10 @@ class GenerateDocumentationTest extends TestCase
|
|
|
config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
|
|
|
$this->artisan('apidoc:generate');
|
|
|
|
|
|
- $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'));
|
|
|
- $generatedCollection->info->_postman_id = '';
|
|
|
- $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection.json'));
|
|
|
+ $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'), true);
|
|
|
+ // The Postman ID varies from call to call; erase it to make the test data reproducible.
|
|
|
+ $generatedCollection['info']['_postman_id'] = '';
|
|
|
+ $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection.json'), true);
|
|
|
$this->assertEquals($generatedCollection, $fixtureCollection);
|
|
|
}
|
|
|
|
|
@@ -273,9 +274,62 @@ class GenerateDocumentationTest extends TestCase
|
|
|
config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
|
|
|
$this->artisan('apidoc:generate');
|
|
|
|
|
|
- $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'));
|
|
|
- $generatedCollection->info->_postman_id = '';
|
|
|
- $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection_updated_url.json'));
|
|
|
+ $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'), true);
|
|
|
+ // The Postman ID varies from call to call; erase it to make the test data reproducible.
|
|
|
+ $generatedCollection['info']['_postman_id'] = '';
|
|
|
+ $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection_updated_url.json'), true);
|
|
|
+ $this->assertEquals($generatedCollection, $fixtureCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function generated_postman_collection_can_append_custom_http_headers()
|
|
|
+ {
|
|
|
+ RouteFacade::get('/api/headers', TestController::class.'@checkCustomHeaders');
|
|
|
+ config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
|
|
|
+ config([
|
|
|
+ 'apidoc.routes.0.apply.headers' => [
|
|
|
+ 'Authorization' => 'customAuthToken',
|
|
|
+ 'Custom-Header' => 'NotSoCustom',
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ $this->artisan('apidoc:generate');
|
|
|
+
|
|
|
+ $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'), true);
|
|
|
+ // The Postman ID varies from call to call; erase it to make the test data reproducible.
|
|
|
+ $generatedCollection['info']['_postman_id'] = '';
|
|
|
+ $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection_with_custom_headers.json'), true);
|
|
|
+ $this->assertEquals($generatedCollection, $fixtureCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function generated_postman_collection_can_have_query_parameters()
|
|
|
+ {
|
|
|
+ RouteFacade::get('/api/withQueryParameters', TestController::class.'@withQueryParameters');
|
|
|
+ // We want to have the same values for params each time
|
|
|
+ config(['apidoc.faker_seed' => 1234]);
|
|
|
+ config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
|
|
|
+ $this->artisan('apidoc:generate');
|
|
|
+
|
|
|
+ $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'), true);
|
|
|
+ // The Postman ID varies from call to call; erase it to make the test data reproducible.
|
|
|
+ $generatedCollection['info']['_postman_id'] = '';
|
|
|
+ $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection_with_query_parameters.json'), true);
|
|
|
+ $this->assertEquals($generatedCollection, $fixtureCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function generated_postman_collection_can_add_body_parameters()
|
|
|
+ {
|
|
|
+ RouteFacade::get('/api/withBodyParameters', TestController::class.'@withBodyParameters');
|
|
|
+ // We want to have the same values for params each time
|
|
|
+ config(['apidoc.faker_seed' => 1234]);
|
|
|
+ config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
|
|
|
+ $this->artisan('apidoc:generate');
|
|
|
+
|
|
|
+ $generatedCollection = json_decode(file_get_contents(__DIR__.'/../public/docs/collection.json'), true);
|
|
|
+ // The Postman ID varies from call to call; erase it to make the test data reproducible.
|
|
|
+ $generatedCollection['info']['_postman_id'] = '';
|
|
|
+ $fixtureCollection = json_decode(file_get_contents(__DIR__.'/Fixtures/collection_with_body_parameters.json'), true);
|
|
|
$this->assertEquals($generatedCollection, $fixtureCollection);
|
|
|
}
|
|
|
|