Skip to content

Commit e2cac01

Browse files
authored
Merge pull request #146 from hans-thomas/cover-GetDependenciesTrait
Cover GetDependenciesTrait
2 parents eeaab2f + c5ac94d commit e2cac01

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

tests/SwaggerServiceTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
use RonasIT\AutoDoc\Exceptions\UnsupportedDocumentationViewerException;
2626
use RonasIT\AutoDoc\Exceptions\WrongSecurityConfigException;
2727
use RonasIT\AutoDoc\Services\SwaggerService;
28+
use RonasIT\AutoDoc\Tests\Support\Mock\TestContract;
2829
use RonasIT\AutoDoc\Tests\Support\Mock\TestNotificationSetting;
30+
use RonasIT\AutoDoc\Tests\Support\Mock\TestRequest;
2931
use RonasIT\AutoDoc\Tests\Support\Traits\SwaggerServiceMockTrait;
3032
use stdClass;
3133

@@ -683,6 +685,61 @@ public function testAddDataPostRequestWithObjectParams()
683685
$service->addData($request, $response);
684686
}
685687

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+
686743
public function testCutExceptions()
687744
{
688745
$this->mockDriverGetEmptyAndSaveTmpData($this->getJsonFixture('tmp_data_create_user_request'));

tests/support/Mock/TestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testRequestWithAnnotations(TestRequestWithAnnotations $request)
1616
{
1717
}
1818

19-
public function testRequestWithContract(TestContract $contract)
19+
public function testRequestWithContract(TestContract $contract, string $param)
2020
{
2121
}
2222
}

0 commit comments

Comments
 (0)