Added markdown generation test

This commit is contained in:
Marcel Pociot
2016-06-13 13:36:55 +02:00
parent 8b72eae449
commit be681d29c1
2 changed files with 74 additions and 0 deletions

61
tests/Fixtures/index.md Normal file
View File

@@ -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`

View File

@@ -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