Download the PHP package deozza/philarmony-api-tester-bundle without Composer
On this page you can find all versions of the php package deozza/philarmony-api-tester-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deozza/philarmony-api-tester-bundle
More information about deozza/philarmony-api-tester-bundle
Files in deozza/philarmony-api-tester-bundle
Package philarmony-api-tester-bundle
Short Description A bundle to test Symfony API
License MIT
Informations about the package philarmony-api-tester-bundle
PhilarmonyApiTester
Table of contents
- About
- Installation
- Database preparation
- How to use
- Folder structure
- Road map
About
PhilarmonyApiTester is a bundle made to test your API. It ensures the quality and the sturdiness of your application via unit and scenario testing.
Installation
You can install using composer, assuming it is already installed globally :
composer require deozza/philarmony-api-tester-bundle
Database preparation
You need to create a database specifically for your tests. To ensure the tests are executed with the same environment and database, this one will be reset at the end of each test.
We recommend the use of doctrine/doctrine-fxtures-bundle for the creation of a test database.
The database you use for the tests could be in MySQL or SQLITE3.
- In the case you are using a MySQL database, you need to export it as a file, name it
demo.sql
{ and store it as a file in the/var/data/db_test
folder. - In the case you are using a SQLITE3 database, you need to name it
demo.sqlite
{ and store it as a file in the/var/data/db_test
folder.
For performance reasons, we recommend using a SQLITE3 database for your tests.
How to use
Creating a ControllerTest
To tests a feature of your application, you need to create a folder in the test
folder. Inside it, create a ControllerTest for each Controller related to that feature. The ControllerTest must match the following example:
Writing tests
The tests are written as an array following this structure:
They are written in the function addDataProvider
.
Key | Description | Facultative |
---|---|---|
kind | The kind of test you are executing | No |
test | The content of the test | No |
test.method | The method of the request you are sending | No |
test.url | The route you are testing | No |
test.token | The authorization token used for the test | Yes |
test.status | The expected http status of the response | No |
test.in | The payload sent with the request | Yes |
test.out | The expected response from the request | Tes |
For now, only GET, POST, PUT, PATCH and DELETE methods are handled by PhilarmonyApiTester
Different kinds of tests
With PhilarmonyApiTester, you are able to test your application by sending requests one by one ("unit" testing) and by sending a group of request ("scenario").
- Read more
In (payloads)
You are able to test your application by sending a specific payload with the in
option and check how it reacts.
- Read more
Out (expected responses)
You are able to check the response of the requests you have sent with the option out
.
- Read more
Testing with patterns
Sometimes, value sent by your app are hard to test because they are unpredictable. Testing with patterns will allow PhilarmonyApiTester to assert these values are in a specific scope and even manipulate them for future tests.
- Read more
Folder structure
To test your application, you need to match the following folder structure:
.
├── tests # The basic Symfony test directory
│ ├── Foo # Feature you need to test
│ │ │── FooControllerTest.php # Controller of the feature you want to test
│ │ │
│ │ ├── Payloads
│ │ │ └── ... # File posted to your API
│ │ │
│ │ └── Responses # All the expected responses coming from the endpoints of your API when testing it
│ │ └── ...
│ └──
└──
Road map
Nothing is in the road map !
All versions of philarmony-api-tester-bundle with dependencies
symfony/phpunit-bridge Version ^4.2.0 || ^4.3.0
symfony/browser-kit Version ^4.2.0 || ^4.3.0
symfony/dotenv Version ^4.2.0 || ^4.3.0
guzzlehttp/guzzle Version ^6.3