pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
298 stars 443 forks source link

Add tests for the REST API #2875

Open NateWr opened 6 years ago

NateWr commented 6 years ago

We should introduce tests for the REST API in OJS. It looks like some tools exist for generating tests from a swagger.yaml file. This would be great if we can integreate it. It will allow us to design the documentation and tests first, and build the API to match the tests.

swagger-codegen seems to build tests for PHPUnit: https://github.com/swagger-api/swagger-codegen/issues/2276

swagger-test looks like another toolset to investigate: https://github.com/byjg/php-swagger-test

cc @kaschioudi

NateWr commented 6 years ago

I'd love an assist on this one from someone with PHPUnit experience. :smile:

asmecher commented 6 years ago

Catch me on Slack!

kaschioudi commented 6 years ago

@NateWr and @asmecher

Here's an initial work.

https://github.com/kaschioudi/ojs3-rest-api-tests

Please take a look and give your feedback. thanks.

asmecher commented 6 years ago

@kaschioudi, rather than writing these as a separate repository, I'd suggest putting them alongside the existing tests in lib/pkp/tests (for shared code) and tests (for OJS-specific tests). There are patterns there to follow for existing tests.

asmecher commented 6 years ago

(https://pkp.sfu.ca/wiki/index.php?title=Developer_Documentation#Testing is dated but has some information on how to get the current unit tests etc. running locally.)

kaschioudi commented 6 years ago

@asmecher : Alright. Actually this was just in order to validate the approach. Anyhow, I will checkout the existing codebase and consolidate everything.

kaschioudi commented 6 years ago

https://github.com/pkp/pkp-lib/pull/3690 https://github.com/pkp/ojs/pull/1965

asmecher commented 6 years ago

Thanks, @kaschioudi -- I've added some comments to the PRs. Generally this is taking shape well, but needs some sharing with the pkp-lib library where possible, and I'm also interested in using the Swagger doc to validate rather than writing assertions that partially reiterate what it already declares.