-
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.
Merge pull request #62 from rakutentech/feature/ui
Fixes #3
- Loading branch information
Showing
10 changed files
with
251 additions
and
32 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
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,42 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests; | ||
use Route; | ||
|
||
class LRDTest extends TestCase | ||
{ | ||
public function testDocsCount() | ||
{ | ||
$docs = $this->lrd->getDocs(); | ||
$routes = collect(Route::getRoutes()); | ||
|
||
$this->assertSame($routes->count(), count($docs)); | ||
} | ||
|
||
public function testDocsCanFetchAllMethods() | ||
{ | ||
$docs = $this->lrd->getDocs(); | ||
$methods = []; | ||
foreach ($docs as $doc) { | ||
$methods = array_merge($methods, $doc['methods']); | ||
} | ||
$methods = array_unique($methods); | ||
sort($methods); | ||
$this->assertSame(['DELETE', 'GET', 'HEAD', 'POST', 'PUT'], $methods); | ||
} | ||
|
||
public function testDocsCanFetchInfo() | ||
{ | ||
$docs = $this->lrd->getDocs(); | ||
foreach ($docs as $doc) { | ||
$this->assertNotEmpty($doc['rules']); | ||
$this->assertNotEmpty($doc['methods']); | ||
// $this->assertNotEmpty($doc['middlewares']); //todo: add middlewares to test | ||
$this->assertNotEmpty($doc['controller']); | ||
$this->assertNotEmpty($doc['controller_full_path']); | ||
$this->assertNotEmpty($doc['method']); | ||
$this->assertNotEmpty($doc['httpMethod']); | ||
$this->assertNotEmpty($doc['rules']); | ||
} | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestControllers; | ||
|
||
use Rakutentech\LaravelRequestDocs\Tests\TestRequests\WelcomeIndexRequest; | ||
use Rakutentech\LaravelRequestDocs\Tests\TestRequests\WelcomeEditRequest; | ||
use Rakutentech\LaravelRequestDocs\Tests\TestRequests\WelcomeStoreRequest; | ||
use Rakutentech\LaravelRequestDocs\Tests\TestRequests\WelcomeDeleteRequest; | ||
|
||
class WelcomeController | ||
{ | ||
public function index(WelcomeIndexRequest $request) | ||
{ | ||
return 1; | ||
} | ||
|
||
public function edit(WelcomeEditRequest $request) | ||
{ | ||
return 1; | ||
} | ||
|
||
public function store(WelcomeStoreRequest $request) | ||
{ | ||
return 1; | ||
} | ||
|
||
public function destroy(WelcomeDeleteRequest $request) | ||
{ | ||
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,34 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestRequests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class WelcomeDeleteRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
protected function prepareForValidation() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'message_param' => 'nullable|string', | ||
]; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestRequests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class WelcomeEditRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
protected function prepareForValidation() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'message_param' => 'nullable|string', | ||
]; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestRequests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class WelcomeIndexRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
protected function prepareForValidation() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'page' => 'nullable|integer|min:1', | ||
'per_page' => 'nullable|integer|min:1|max:100', | ||
]; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Rakutentech\LaravelRequestDocs\Tests\TestRequests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class WelcomeStoreRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
protected function prepareForValidation() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'message_param' => 'nullable|string', | ||
]; | ||
} | ||
} |