-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
198 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ vendor | |
node_modules | ||
.php-cs-fixer.cache | ||
.DS_Store | ||
_ide_helper.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\Feature\Commands; | ||
|
||
use Illuminate\Support\Facades\File; | ||
use Rakutentech\LaravelRequestDocs\Tests\TestCase; | ||
|
||
class LaravelRequestDocsCommandTest extends TestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
File::deleteDirectory(config('request-docs.docs_path')); | ||
File::deleteDirectory(base_path('docs/request-docs/')); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function testHandle() | ||
{ | ||
$this->assertFalse(File::exists(config('request-docs.docs_path') . '/index.html')); | ||
$this->assertFalse(File::exists(config('request-docs.docs_path') . '/lrd-openapi.json')); | ||
|
||
$this->artisan('lrd:generate') | ||
->assertExitCode(0); | ||
|
||
$this->assertTrue(File::exists(config('request-docs.docs_path') . '/index.html')); | ||
$this->assertTrue(File::exists(config('request-docs.docs_path') . '/lrd-openapi.json')); | ||
|
||
config('request-docs.docs_path'); | ||
} | ||
|
||
public function testWillCreateDirectory() | ||
{ | ||
File::deleteDirectory(config('request-docs.docs_path')); | ||
$this->assertFalse(File::exists(config('request-docs.docs_path'))); | ||
|
||
$this->artisan('lrd:generate') | ||
->assertExitCode(0); | ||
|
||
$this->assertTrue(File::exists(config('request-docs.docs_path'))); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Feature/Controllers/LaravelRequestDocsControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\Feature\Controllers; | ||
|
||
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\Config; | ||
use Rakutentech\LaravelRequestDocs\Tests\TestCase; | ||
|
||
class LaravelRequestDocsControllerTest extends TestCase | ||
{ | ||
public function testIndex() | ||
{ | ||
$this->get(config('request-docs.url')) | ||
->assertStatus(Response::HTTP_OK); | ||
} | ||
|
||
public function testSortDocsByDefault() | ||
{ | ||
Config::set('request-docs.sort_by', 'default'); | ||
$this->get(config('request-docs.url')) | ||
->assertStatus(Response::HTTP_OK); | ||
} | ||
|
||
public function testOpenAPI() | ||
{ | ||
$this->get(config('request-docs.url') . '?openapi=true') | ||
->assertStatus(Response::HTTP_OK); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests; | ||
use Route; | ||
|
||
class LRDOpenApiTest extends TestCase | ||
{ | ||
public function testDocsCount() | ||
{ | ||
$docs = $this->lrd->getDocs(); | ||
$openApi = $this->lrdToOpenApi->openApi($docs)->toArray(); | ||
$routes = collect(Route::getRoutes()); | ||
|
||
$this->assertSame($routes->count(), count($docs)); | ||
$this->assertSame($this->countRoutesWithLRDDoc(), count($docs)); | ||
|
||
$countRoutes = 0; | ||
foreach ($openApi["paths"] as $path) { | ||
$countRoutes += count(array_keys($path)); | ||
} | ||
|
||
$this->assertSame($routes->count(), $countRoutes); | ||
$this->assertSame($this->countRoutesWithLRDDoc(), $countRoutes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestControllers; | ||
|
||
/** | ||
* Single action controller with a single `__invoke` method | ||
* | ||
* @see https://laravel.com/docs/controllers#single-action-controllers | ||
*/ | ||
class SingleActionController | ||
{ | ||
public function __invoke() | ||
{ | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestControllers; | ||
|
||
class TelescopeController | ||
{ | ||
/** | ||
* For `config('request-docs.hide_matching')` test. | ||
* | ||
* @return int | ||
*/ | ||
public function index() | ||
{ | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.