Browse Source

Add tests for prependinf and appending markdown (#191)

shalvah 6 years ago
parent
commit
70c0cda1cf
4 changed files with 31 additions and 2 deletions
  1. 2 2
      README.md
  2. 3 0
      tests/Fixtures/append.md
  3. 3 0
      tests/Fixtures/prepend.md
  4. 23 0
      tests/GenerateDocumentationTest.php

+ 2 - 2
README.md

@@ -244,8 +244,8 @@ As an optional parameter, you can use `--location` to tell the update command wh
  If you wish to automatically add the same content to the docs every time you generate, you can add a `prepend.md` and/or `append.md` file to the source folder, and they will be included above and below the generated documentation.
  If you wish to automatically add the same content to the docs every time you generate, you can add a `prepend.md` and/or `append.md` file to the source folder, and they will be included above and below the generated documentation.
  
  
  **File locations:**
  **File locations:**
-- `public/docs/source/prepend.md`
-- `public/docs/source/append.md`
+- `public/docs/source/prepend.md` - Will be added after the front matter and info text
+- `public/docs/source/append.md` - Will be added at the end of the document
 
 
 ## Skip single routes
 ## Skip single routes
 
 

+ 3 - 0
tests/Fixtures/append.md

@@ -0,0 +1,3 @@
+# Appended Markdown
+
+This markdown should be added to the end of generated docs

+ 3 - 0
tests/Fixtures/prepend.md

@@ -0,0 +1,3 @@
+# Prepended Markdown
+
+This markdown should be added to the start of generated docs

+ 23 - 0
tests/GenerateDocumentationTest.php

@@ -143,6 +143,29 @@ class GenerateDocumentationTest extends TestCase
         $this->assertFilesHaveSameContent($fixtureMarkdown, $compareMarkdown);
         $this->assertFilesHaveSameContent($fixtureMarkdown, $compareMarkdown);
     }
     }
 
 
+    public function testCanPrependAndAppendDataToGeneratedMarkdown()
+    {
+        RouteFacade::get('/api/test', TestController::class.'@parseMethodDescription');
+        RouteFacade::get('/api/fetch', TestController::class.'@fetchRouteResponse');
+
+        $this->artisan('api:generate', [
+            '--routePrefix' => 'api/*',
+        ]);
+
+        $prependMarkdown = __DIR__.'/Fixtures/prepend.md';
+        $appendMarkdown = __DIR__.'/Fixtures/append.md';
+        copy($prependMarkdown, __DIR__.'/../public/docs/source/prepend.md');
+        copy($appendMarkdown, __DIR__.'/../public/docs/source/append.md');
+
+        $this->artisan('api:generate', [
+            '--routePrefix' => 'api/*',
+        ]);
+
+        $generatedMarkdown = __DIR__.'/../public/docs/source/index.md';
+        $this->assertContainsRaw($this->getFileContents($prependMarkdown), $this->getFileContents($generatedMarkdown));
+        $this->assertContainsRaw($this->getFileContents($appendMarkdown), $this->getFileContents($generatedMarkdown));
+    }
+
     public function testAddsBindingsToGetRouteRules()
     public function testAddsBindingsToGetRouteRules()
     {
     {
         RouteFacade::get('/api/test/{foo}', TestController::class.'@addRouteBindingsToRequestClass');
         RouteFacade::get('/api/test/{foo}', TestController::class.'@addRouteBindingsToRequestClass');