Skip to content

Commit 3506f8f

Browse files
committed
fix: use invocable controllers with DI with bind by contracts
1 parent ed65112 commit 3506f8f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/SwaggerServiceTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ public function testAddDataWhenInvokableClass()
876876
app(SwaggerService::class)->addData($request, $response);
877877
}
878878

879-
public function testAddDataWhenInvokableClassWithBindingContract()
879+
public function testAddDataWhenInvokableClassWithBindingContractToObject()
880880
{
881881
$this->mockDriverGetEmptyAndSaveProcessTmpData($this->getJsonFixture('tmp_data_get_user_request_invoke_bind_closure'));
882882

@@ -895,4 +895,24 @@ public function testAddDataWhenInvokableClassWithBindingContract()
895895

896896
app(SwaggerService::class)->addData($request, $response);
897897
}
898+
899+
public function testAddDataWhenInvokableClassWithBindingContractToClassName()
900+
{
901+
$this->mockDriverGetEmptyAndSaveProcessTmpData($this->getJsonFixture('tmp_data_get_user_request_invoke_bind_closure'));
902+
903+
$this->app->bind(TestRequestContract::class, TestRequest::class);
904+
905+
$request = $this->generateRequest(
906+
type: 'get',
907+
uri: 'users',
908+
controllerMethod: '__invoke',
909+
controllerClass: InvokableTestController::class,
910+
);
911+
912+
$response = $this->generateResponse('example_success_user_response.json', 200, [
913+
'Content-type' => 'application/json',
914+
]);
915+
916+
app(SwaggerService::class)->addData($request, $response);
917+
}
898918
}

0 commit comments

Comments
 (0)