|
25 | 25 | use RonasIT\AutoDoc\Exceptions\UnsupportedDocumentationViewerException; |
26 | 26 | use RonasIT\AutoDoc\Exceptions\WrongSecurityConfigException; |
27 | 27 | use RonasIT\AutoDoc\Services\SwaggerService; |
| 28 | +use RonasIT\AutoDoc\Tests\Support\Mock\TestContract; |
28 | 29 | use RonasIT\AutoDoc\Tests\Support\Mock\TestNotificationSetting; |
| 30 | +use RonasIT\AutoDoc\Tests\Support\Mock\TestRequest; |
29 | 31 | use RonasIT\AutoDoc\Tests\Support\Traits\SwaggerServiceMockTrait; |
30 | 32 | use stdClass; |
31 | 33 |
|
@@ -683,6 +685,61 @@ public function testAddDataPostRequestWithObjectParams() |
683 | 685 | $service->addData($request, $response); |
684 | 686 | } |
685 | 687 |
|
| 688 | + public function testAddDataWithNotExistsMethodOnController() |
| 689 | + { |
| 690 | + $this->mockDriverGetTmpData($this->getJsonFixture('tmp_data_get_user_request')); |
| 691 | + |
| 692 | + $service = app(SwaggerService::class); |
| 693 | + |
| 694 | + $request = $this->generateRequest( |
| 695 | + type: 'get', |
| 696 | + uri: 'users/{id}/assign-role/{role-id}', |
| 697 | + data: [ |
| 698 | + 'with' => ['role'], |
| 699 | + 'with_likes_count' => true, |
| 700 | + ], |
| 701 | + pathParams: [ |
| 702 | + 'id' => 1, |
| 703 | + 'role-id' => 5, |
| 704 | + ], |
| 705 | + controllerMethod: 'notExists' |
| 706 | + ); |
| 707 | + |
| 708 | + $response = $this->generateResponse('example_success_user_response.json', 200, [ |
| 709 | + 'Content-type' => 'application/json', |
| 710 | + ]); |
| 711 | + |
| 712 | + $service->addData($request, $response); |
| 713 | + } |
| 714 | + |
| 715 | + public function testAddDataWithBindingInterface() |
| 716 | + { |
| 717 | + $this->app->bind(TestContract::class, TestRequest::class); |
| 718 | + $this->mockDriverGetEmptyAndSaveTmpData($this->getJsonFixture('tmp_data_get_user_request')); |
| 719 | + |
| 720 | + $service = app(SwaggerService::class); |
| 721 | + |
| 722 | + $request = $this->generateRequest( |
| 723 | + type: 'get', |
| 724 | + uri: 'users/{id}/assign-role/{role-id}', |
| 725 | + data: [ |
| 726 | + 'with' => ['role'], |
| 727 | + 'with_likes_count' => true, |
| 728 | + ], |
| 729 | + pathParams: [ |
| 730 | + 'id' => 1, |
| 731 | + 'role-id' => 5, |
| 732 | + ], |
| 733 | + controllerMethod: 'testRequestWithContract' |
| 734 | + ); |
| 735 | + |
| 736 | + $response = $this->generateResponse('example_success_user_response.json', 200, [ |
| 737 | + 'Content-type' => 'application/json', |
| 738 | + ]); |
| 739 | + |
| 740 | + $service->addData($request, $response); |
| 741 | + } |
| 742 | + |
686 | 743 | public function testCutExceptions() |
687 | 744 | { |
688 | 745 | $this->mockDriverGetEmptyAndSaveTmpData($this->getJsonFixture('tmp_data_create_user_request')); |
|
0 commit comments