Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Oct 11, 2018
1 parent 73dee2b commit 1418ed9
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 74 deletions.
19 changes: 14 additions & 5 deletions tests/Fixtures/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function withEndpointDescription()
* @bodyParam user_id int required The id of the user.
* @bodyParam room_id string The id of the room.
*/
public function withBodyParameters(TestRequest $request)
public function withBodyParameters()
{
return '';
}
Expand All @@ -36,7 +36,7 @@ public function checkCustomHeaders(Request $request)
return $request->headers->all();
}

public function fetchRouteResponse()
public function shouldFetchRouteResponse()
{
$fixture = new \stdClass();
$fixture->id = 1;
Expand All @@ -54,7 +54,12 @@ public function fetchRouteResponse()
];
}

public function utf8()
/**
* @response {
* "result": "Лорем ипсум долор сит амет"
* }
*/
public function withUtf8ResponseTag()
{
return ['result' => 'Лорем ипсум долор сит амет'];
}
Expand All @@ -68,8 +73,12 @@ public function skip()

/**
* @response {
* "data": []
*}
* "id": 4,
* "name": "banana",
* "color": "red",
* "weight": "1 kg",
* "delicious": true
* }
*/
public function withResponseTag()
{
Expand Down
16 changes: 16 additions & 0 deletions tests/Fixtures/TestResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class TestResourceController extends Controller
/**
* Display a listing of the resource.
*
* @response {
* "index_resource": true
* }
*
* @return \Illuminate\Http\Response
*/
public function index()
Expand All @@ -22,6 +26,10 @@ public function index()
/**
* Show the form for creating a new resource.
*
* @response {
* "create_resource": true
* }
*
* @return \Illuminate\Http\Response
*/
public function create()
Expand All @@ -48,6 +56,10 @@ public function store(Request $request)
/**
* Display the specified resource.
*
* @response {
* "show_resource": true
* }
*
* @param int $id
*
* @return \Illuminate\Http\Response
Expand All @@ -62,6 +74,10 @@ public function show($id)
/**
* Show the form for editing the specified resource.
*
* @response {
* "edit_resource": true
* }
*
* @param int $id
*
* @return \Illuminate\Http\Response
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/collection.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"variables":[],"info":{"name":"","_postman_id":"","description":"","schema":"https:\/\/schema.getpostman.com\/json\/collection\/v2.0.0\/collection.json"},"item":[{"name":"general","description":"","item":[{"name":"Example title.","request":{"url":"http:\/\/localhost\/api\/test","method":"GET","body":{"mode":"formdata","formdata":[]},"description":"This will be the long description.\nIt can also be multiple lines long.","response":[]}},{"name":"http:\/\/localhost\/api\/fetch","request":{"url":"http:\/\/localhost\/api\/fetch","method":"POST","body":{"mode":"formdata","formdata":[]},"description":"","response":[]}}]}]}
{"variables":[],"info":{"name":"","_postman_id":"","description":"","schema":"https:\/\/schema.getpostman.com\/json\/collection\/v2.0.0\/collection.json"},"item":[{"name":"general","description":"","item":[{"name":"Example title.","request":{"url":"http:\/\/localhost\/api\/test","method":"GET","body":{"mode":"formdata","formdata":[]},"description":"This will be the long description.\nIt can also be multiple lines long.","response":[]}},{"name":"http:\/\/localhost\/api\/responseTag","request":{"url":"http:\/\/localhost\/api\/responseTag","method":"POST","body":{"mode":"formdata","formdata":[]},"description":"","response":[]}}]}]}
24 changes: 12 additions & 12 deletions tests/Fixtures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var settings = {
"url": "http://localhost/api/test",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -62,24 +62,24 @@ null

<!-- END_0bef4e738c9d6720ad43b062015d1078 -->

<!-- START_960a1b2b0f0f4dde8ce993307397f9c4 -->
## api/fetch
<!-- START_39a6bfda1d6a0c4a5447f51b62557456 -->
## api/responseTag

> Example request:
```bash
curl -X GET -G "http://localhost/api/fetch" \
curl -X GET -G "http://localhost/api/responseTag" \
-H "Accept: application/json"
```

```javascript
var settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost/api/fetch",
"url": "http://localhost/api/responseTag",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -92,18 +92,18 @@ $.ajax(settings).done(function (response) {
```json
{
"id": 1,
"name": "Banana",
"color": "Red",
"weight": "300 grams",
"id": 4,
"name": "banana",
"color": "red",
"weight": "1 kg",
"delicious": true
}
```

### HTTP Request
`GET api/fetch`
`GET api/responseTag`


<!-- END_960a1b2b0f0f4dde8ce993307397f9c4 -->
<!-- END_39a6bfda1d6a0c4a5447f51b62557456 -->


12 changes: 6 additions & 6 deletions tests/Fixtures/partial_resource_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Welcome to the generated API reference.
<!-- END_INFO -->

#general
<!-- START_2b6e5a4b188cb183c7e59558cce36cb6 -->
<!-- START_fc1e4f6a697e3c48257de845299b71d5 -->
## Display a listing of the resource.

> Example request:
Expand All @@ -38,7 +38,7 @@ var settings = {
"url": "http://localhost/api/users",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -59,9 +59,9 @@ $.ajax(settings).done(function (response) {
`GET api/users`


<!-- END_2b6e5a4b188cb183c7e59558cce36cb6 -->
<!-- END_fc1e4f6a697e3c48257de845299b71d5 -->

<!-- START_7f66c974d24032cb19061d55d801f62b -->
<!-- START_5dac10bb34c7618b018b0230d4a51648 -->
## Show the form for creating a new resource.

> Example request:
Expand All @@ -78,7 +78,7 @@ var settings = {
"url": "http://localhost/api/users/create",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -99,6 +99,6 @@ $.ajax(settings).done(function (response) {
`GET api/users/create`


<!-- END_7f66c974d24032cb19061d55d801f62b -->
<!-- END_5dac10bb34c7618b018b0230d4a51648 -->


46 changes: 23 additions & 23 deletions tests/Fixtures/resource_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Welcome to the generated API reference.
<!-- END_INFO -->

#general
<!-- START_2b6e5a4b188cb183c7e59558cce36cb6 -->
<!-- START_fc1e4f6a697e3c48257de845299b71d5 -->
## Display a listing of the resource.

> Example request:
Expand All @@ -38,7 +38,7 @@ var settings = {
"url": "http://localhost/api/users",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -59,9 +59,9 @@ $.ajax(settings).done(function (response) {
`GET api/users`


<!-- END_2b6e5a4b188cb183c7e59558cce36cb6 -->
<!-- END_fc1e4f6a697e3c48257de845299b71d5 -->

<!-- START_7f66c974d24032cb19061d55d801f62b -->
<!-- START_5dac10bb34c7618b018b0230d4a51648 -->
## Show the form for creating a new resource.

> Example request:
Expand All @@ -78,7 +78,7 @@ var settings = {
"url": "http://localhost/api/users/create",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -99,9 +99,9 @@ $.ajax(settings).done(function (response) {
`GET api/users/create`


<!-- END_7f66c974d24032cb19061d55d801f62b -->
<!-- END_5dac10bb34c7618b018b0230d4a51648 -->

<!-- START_f0654d3f2fc63c11f5723f233cc53c83 -->
<!-- START_12e37982cc5398c7100e59625ebb5514 -->
## Store a newly created resource in storage.

> Example request:
Expand All @@ -118,7 +118,7 @@ var settings = {
"url": "http://localhost/api/users",
"method": "POST",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -132,9 +132,9 @@ $.ajax(settings).done(function (response) {
`POST api/users`


<!-- END_f0654d3f2fc63c11f5723f233cc53c83 -->
<!-- END_12e37982cc5398c7100e59625ebb5514 -->

<!-- START_ceec0e0b1d13d731ad96603d26bccc2f -->
<!-- START_8653614346cb0e3d444d164579a0a0a2 -->
## Display the specified resource.

> Example request:
Expand All @@ -151,7 +151,7 @@ var settings = {
"url": "http://localhost/api/users/{user}",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -164,17 +164,17 @@ $.ajax(settings).done(function (response) {
```json
{
"show_resource": "1"
"show_resource": true
}
```

### HTTP Request
`GET api/users/{user}`


<!-- END_ceec0e0b1d13d731ad96603d26bccc2f -->
<!-- END_8653614346cb0e3d444d164579a0a0a2 -->

<!-- START_f4aa12af19ba08e1448d7eafc9f55e67 -->
<!-- START_11ae28146a4d70ba9a0af9b65d290ad5 -->
## Show the form for editing the specified resource.

> Example request:
Expand All @@ -191,7 +191,7 @@ var settings = {
"url": "http://localhost/api/users/{user}/edit",
"method": "GET",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -204,17 +204,17 @@ $.ajax(settings).done(function (response) {
```json
{
"edit_resource": "1"
"edit_resource": true
}
```

### HTTP Request
`GET api/users/{user}/edit`


<!-- END_f4aa12af19ba08e1448d7eafc9f55e67 -->
<!-- END_11ae28146a4d70ba9a0af9b65d290ad5 -->

<!-- START_a4a2abed1e8e8cad5e6a3282812fe3f3 -->
<!-- START_48a3115be98493a3c866eb0e23347262 -->
## Update the specified resource in storage.

> Example request:
Expand All @@ -231,7 +231,7 @@ var settings = {
"url": "http://localhost/api/users/{user}",
"method": "PUT",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -247,9 +247,9 @@ $.ajax(settings).done(function (response) {
`PATCH api/users/{user}`


<!-- END_a4a2abed1e8e8cad5e6a3282812fe3f3 -->
<!-- END_48a3115be98493a3c866eb0e23347262 -->

<!-- START_4bb7fb4a7501d3cb1ed21acfc3b205a9 -->
<!-- START_d2db7a9fe3abd141d5adbc367a88e969 -->
## Remove the specified resource from storage.

> Example request:
Expand All @@ -266,7 +266,7 @@ var settings = {
"url": "http://localhost/api/users/{user}",
"method": "DELETE",
"headers": {
"accept": "application/json"
"accept": "application/json",
}
}

Expand All @@ -280,6 +280,6 @@ $.ajax(settings).done(function (response) {
`DELETE api/users/{user}`


<!-- END_4bb7fb4a7501d3cb1ed21acfc3b205a9 -->
<!-- END_d2db7a9fe3abd141d5adbc367a88e969 -->


Loading

0 comments on commit 1418ed9

Please sign in to comment.