浏览代码

Added markdown generation test

Marcel Pociot 9 年之前
父节点
当前提交
be681d29c1
共有 2 个文件被更改,包括 74 次插入0 次删除
  1. 61 0
      tests/Fixtures/index.md
  2. 13 0
      tests/GenerateDocumentationTest.php

+ 61 - 0
tests/Fixtures/index.md

@@ -0,0 +1,61 @@
+---
+title: API Reference
+
+language_tabs:
+- bash
+- javascript
+
+includes:
+
+search: true
+
+toc_footers:
+- <a href='http://github.com/mpociot/documentarian'>Documentation Powered by Documentarian</a>
+---
+
+# Info
+
+Welcome to the generated API reference.
+
+# Available routes
+#general
+## Example title.
+
+This will be the long description.
+It can also be multiple lines long.
+
+> Example request:
+
+```bash
+curl "http://localhost/api/test" \
+-H "Accept: application/json"
+```
+
+```javascript
+var settings = {
+    "async": true,
+    "crossDomain": true,
+    "url": "http://localhost/api/test",
+    "method": "GET",
+        "headers": {
+    "accept": "application/json"
+    }
+}
+
+$.ajax(settings).done(function (response) {
+console.log(response);
+});
+```
+
+> Example response:
+
+```json
+null
+```
+
+### HTTP Request
+`GET api/test`
+
+`HEAD api/test`
+
+

+ 13 - 0
tests/GenerateDocumentationTest.php

@@ -57,6 +57,19 @@ class GenerateDocumentationTest extends TestCase
         $this->assertContains('Processed route: api/test', $output);
     }
 
+    public function testGeneratedMarkdownFileIsCorrect()
+    {
+        RouteFacade::get('/api/test', TestController::class.'@parseMethodDescription');
+
+        $output = $this->artisan('api:generate', [
+            '--routePrefix' => 'api/*',
+        ]);
+        
+        $generatedMarkdown = file_get_contents(__DIR__ . '/../public/docs/source/index.md');
+        $fixtureMarkdown   = file_get_contents(__DIR__ . '/Fixtures/index.md');
+        $this->assertSame($generatedMarkdown, $fixtureMarkdown);
+    }
+
     /**
      * @param string $command
      * @param array $parameters