Skip to content

hluchas/api-symfony

Repository files navigation

Test API in Symfony

Task is not complete to all details as mentioned in API doc section. It is not problem to do everything, but I need to save my time.

Build

git clone git@github.com:hluchas/api-symfony.git
cd api-symfony
./build.sh

API doc

Is not complete as there are not mentioned non 200 status codes, validation messages etc. I would need more research in Swagger doc for this.

Tests runner & environment

./test.sh

Used for automated testing. Server is running on different port with different app settings and database connection. Check .env.test file.

Implemented tests are simple unit and API acceptance test with HTTP requests touching API.

XDebug

  • server : 127.0.0.1
  • port : 9002
  • IDE key : PHPSTORM

Remember to use correct path mappings to /war/www/symfony

My requirements

  • Docker
  • FOSRest bundle with proper configuration
  • ParamConverter implementation to simplify API
  • PHPUnit
  • PHPCS fixer
  • PHPSTAN checks
  • PHPUnit test run
  • XDebug enabled for dev env
  • Normalizer for FOSRest exception responses (non 200 OK) to json
  • Normalizer for invalid POST data responses (now it is too complex to read, should be simplified) - Already normalized to easy readable format
  • API versioning - https://symfony.com/doc/current/bundles/FOSRestBundle/versioning.html
  • Swagger for API doc
  • Acceptance API test
  • Acceptance (integration) testing suite - used codeception. Developer must be able to write against these test suites without manually sending requests via Postman.

Missing and should be implemented in CI

  1. Code coverage checks
  2. Codeception implementation in CI