Giter VIP home page Giter VIP logo

vf-test's Introduction

vf-test

This is a simple REST API generated with api-platform. There is only one simple end-point protected by a single token.

Use the API

Launch the environnement with the following command:

make install

At this point, the documentation is already available at http://localhost/api/docs, but the API is still unusable.

Then create the database with the following command:

make create-database

The API can now be used. It is available at http://localhost/api/widgets and can be accessed by your favorite tool.

Testing the API

Launch the automated tests with the following command:

make behat

To test with Postman, there is a collection available for loading. Import the file vf-test.postman_collection.json from Postman to load it and start playing with it.

FAQ

Why did I choose api-platform
It's the most efficient way of generating a REST API that I know of. It helps focussing on what is important in an application. There is no need to spend time on the implementation details of a POST or GET request since it's basically always identical. Thus freeing some time for business logic.

Why did I used behat instead of phpunit
In that particular use-case, there is no value to write unit test (I am not saying that it never has value) since the specific classes are reduced to their minimum. There is no business logic in those classes that needs to be contained and validated. Here, the testing makes more sense to be made at a higher level to validate the API output. But even there, I am basically testing that api-platform is doing it's job properly.

Why the X-Day header is not tested
There is a discrepancy between Behat and Symfony on the dependency injection system. Thus preventing the use of internal classes to create Context test classes. There is an open issue for that particular problem.

Why my data vanished
At the moment, there is only one database shared between the different environnements. Thus, its content is dropped by behat tests. In a real environment, this needs to be addressed to be able to work with confidence.

Why my containers do not start
If the ports used in the docker-compose.yml file are already in use, you need to change the port routing before restarting. You'll need to change the API and the documentation URLs accordingly.

Why my make rules are not working
I've tested those rules only on GNU/Linux (Arch Linux). If you are using a different system, they might be broken. You need to open the Makefile file and run the rule's commands one by one.

How do I change the API token
You need to change the API_TOKEN token value in the .env file. You can do that as well for the .env.test file but this will break behat tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.