Browse Source

#543 Add test for https url, fixture

Nicholas Catanchin 5 years ago
parent
commit
35a7ee8f6a
2 changed files with 72 additions and 0 deletions
  1. 55 0
      tests/Fixtures/collection_with_secure_url.json
  2. 17 0
      tests/GenerateDocumentationTest.php

+ 55 - 0
tests/Fixtures/collection_with_secure_url.json

@@ -0,0 +1,55 @@
+{
+    "variables": [],
+    "info": {
+        "name": "Laravel API",
+        "_postman_id": "",
+        "description": "",
+        "schema": "https:\/\/schema.getpostman.com\/json\/collection\/v2.0.0\/collection.json"
+    },
+    "item": [
+        {
+            "name": "Group A",
+            "description": "",
+            "item": [
+                {
+                    "name": "Example title.",
+                    "request": {
+                        "url": "https:\/\/yourapp.app\/api\/test",
+                        "method": "GET",
+                        "header": [
+                            {
+                                "key": "Accept",
+                                "value": "application/json"
+                            }
+                        ],
+                        "body": {
+                            "mode": "formdata",
+                            "formdata": []
+                        },
+                        "description": "This will be the long description.\nIt can also be multiple lines long.",
+                        "response": []
+                    }
+                },
+                {
+                    "name": "https:\/\/yourapp.app\/api\/responseTag",
+                    "request": {
+                        "url": "https:\/\/yourapp.app\/api\/responseTag",
+                        "method": "POST",
+                        "header": [
+                            {
+                                "key": "Accept",
+                                "value": "application/json"
+                            }
+                        ],
+                        "body": {
+                            "mode": "formdata",
+                            "formdata": []
+                        },
+                        "description": "",
+                        "response": []
+                    }
+                }
+            ]
+        }
+    ]
+}

+ 17 - 0
tests/GenerateDocumentationTest.php

@@ -265,6 +265,23 @@ class GenerateDocumentationTest extends TestCase
         $this->assertEquals($generatedCollection, $fixtureCollection);
     }
 
+    /** @test */
+    public function generated_postman_collection_can_have_secure_url()
+    {
+        Config::set('apidoc.base_url', 'https://yourapp.app');
+        RouteFacade::get('/api/test', TestController::class.'@withEndpointDescription');
+        RouteFacade::post('/api/responseTag', TestController::class.'@withResponseTag');
+
+        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_secure_url.json'), true);
+        $this->assertEquals($generatedCollection, $fixtureCollection);
+    }
+
     /** @test */
     public function generated_postman_collection_can_append_custom_http_headers()
     {