OpenAPITools / OpenAPITools/openapi-generator
[REQ] PHPUnit test generation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
no
Describe the solution you'd like
From the API definition it is possible to generate general end-to-end API tests in a PHPUnit compatible class format. All general things could be an object to be tested. Example: API returns a Content-Type: this could be tested.
Describe alternatives you've considered
Along with the given API specs it is possible to write API tests manually.
Additional context
- https://blog.cloudflare.com/using-guzzle-and-phpunit-for-rest-api-testing/ Excellent example of an API test in PHPUnit format.
This is how to test an endpoint that will respond with 405 on a PUT request:
public function testPut() {
$response = $this->http->request('PUT', 'user-agent', ['http_errors' => false]);
$this->assertEquals(405, $response->getStatusCode());
}
Maybe this is related to #566 but the solution there looks like it is related to slim framework only.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the OpenAPI definition and the generator's PHP output path, then review how generated API tests could represent general response checks. Compare the desired PHPUnit-compatible class with the linked Guzzle example; done means a defined generation scope and working PHPUnit tests for the applicable endpoints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, php
- Domain
- api, testing, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100