/
GeneratorTest.php
86 lines (59 loc) · 2.32 KB
/
GeneratorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Tests;
use SwaggerLume\Generator;
class GeneratorTest extends LumenTestCase
{
/** @test */
public function canGenerateApiJsonAndYamlFile()
{
$this->setPaths();
Generator::generateDocs();
$this->assertTrue(file_exists($this->jsonDocsFile()));
$this->assertTrue(file_exists($this->yamlDocsFile()));
$response = $this->get(config('swagger-lume.routes.docs'));
$this->assertResponseOk();
$this->assertStringContainsString('SwaggerLume', $response->response->getContent());
$this->assertStringContainsString('my-default-host.com', $response->response->getContent());
}
/** @test */
public function canGenerateApiJsonAndYamlFileWithChangedBasePath()
{
if ($this->isOpenApi() == true) {
$this->markTestSkipped('only for openApi 2.0');
}
$this->setPaths();
$cfg = config('swagger-lume');
$cfg['paths']['base'] = '/new_path/is/here';
config(['swagger-lume' => $cfg]);
Generator::generateDocs();
$this->assertTrue(file_exists($this->jsonDocsFile()));
$this->assertTrue(file_exists($this->yamlDocsFile()));
$response = $this->get(config('swagger-lume.routes.docs'));
$this->assertResponseOk();
$this->assertStringContainsString('SwaggerLume', $response->response->getContent());
$this->assertStringContainsString('new_path', $response->response->getContent());
}
/** @test */
public function canSetProxy()
{
$this->setPaths();
$cfg = config('swagger-lume');
$cfg['proxy'] = 'http://proxy.dev';
config(['swagger-lume' => $cfg]);
$this->get(config('swagger-lume.routes.api'));
$this->assertResponseOk();
$this->assertTrue(file_exists($this->jsonDocsFile()));
}
/** @test */
public function canSetValidatorUrl()
{
$this->setPaths();
$cfg = config('swagger-lume');
$cfg['validator_url'] = 'http://validator-url.dev';
config(['swagger-lume' => $cfg]);
$response = $this->get(config('swagger-lume.routes.api'));
$this->assertResponseOk();
$this->assertStringContainsString('validator-url.dev', $response->response->getContent());
$this->assertTrue(file_exists($this->jsonDocsFile()));
}
}