Skip to content

Commit

Permalink
Merge pull request #146 from hans-thomas/cover-GetDependenciesTrait
Browse files Browse the repository at this point in the history
Cover GetDependenciesTrait
  • Loading branch information
DenTray authored Dec 11, 2024
2 parents eeaab2f + c5ac94d commit e2cac01
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions tests/SwaggerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
use RonasIT\AutoDoc\Exceptions\UnsupportedDocumentationViewerException;
use RonasIT\AutoDoc\Exceptions\WrongSecurityConfigException;
use RonasIT\AutoDoc\Services\SwaggerService;
use RonasIT\AutoDoc\Tests\Support\Mock\TestContract;
use RonasIT\AutoDoc\Tests\Support\Mock\TestNotificationSetting;
use RonasIT\AutoDoc\Tests\Support\Mock\TestRequest;
use RonasIT\AutoDoc\Tests\Support\Traits\SwaggerServiceMockTrait;
use stdClass;

Expand Down Expand Up @@ -683,6 +685,61 @@ public function testAddDataPostRequestWithObjectParams()
$service->addData($request, $response);
}

public function testAddDataWithNotExistsMethodOnController()
{
$this->mockDriverGetTmpData($this->getJsonFixture('tmp_data_get_user_request'));

$service = app(SwaggerService::class);

$request = $this->generateRequest(
type: 'get',
uri: 'users/{id}/assign-role/{role-id}',
data: [
'with' => ['role'],
'with_likes_count' => true,
],
pathParams: [
'id' => 1,
'role-id' => 5,
],
controllerMethod: 'notExists'
);

$response = $this->generateResponse('example_success_user_response.json', 200, [
'Content-type' => 'application/json',
]);

$service->addData($request, $response);
}

public function testAddDataWithBindingInterface()
{
$this->app->bind(TestContract::class, TestRequest::class);
$this->mockDriverGetEmptyAndSaveTmpData($this->getJsonFixture('tmp_data_get_user_request'));

$service = app(SwaggerService::class);

$request = $this->generateRequest(
type: 'get',
uri: 'users/{id}/assign-role/{role-id}',
data: [
'with' => ['role'],
'with_likes_count' => true,
],
pathParams: [
'id' => 1,
'role-id' => 5,
],
controllerMethod: 'testRequestWithContract'
);

$response = $this->generateResponse('example_success_user_response.json', 200, [
'Content-type' => 'application/json',
]);

$service->addData($request, $response);
}

public function testCutExceptions()
{
$this->mockDriverGetEmptyAndSaveTmpData($this->getJsonFixture('tmp_data_create_user_request'));
Expand Down
2 changes: 1 addition & 1 deletion tests/support/Mock/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testRequestWithAnnotations(TestRequestWithAnnotations $request)
{
}

public function testRequestWithContract(TestContract $contract)
public function testRequestWithContract(TestContract $contract, string $param)
{
}
}

0 comments on commit e2cac01

Please sign in to comment.