Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ] PHPUnit test generation #4336

Open
powtac opened this issue Oct 31, 2019 · 1 comment
Open

[REQ] PHPUnit test generation #4336

powtac opened this issue Oct 31, 2019 · 1 comment

Comments

@powtac
Copy link

powtac commented Oct 31, 2019

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

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.

@wing328
Copy link
Member

wing328 commented Nov 1, 2019

For PHP clients, there are auto-generated test files, e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php

We can make further enhancements like what you've suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants