This project contains functional tests for the ABTest API. The tests cover various functionalities of the ABTest API, ensuring that the endpoints work as expected.
- test_create_ab_test: Tests the creation of a new AB test. It sends a POST request with the necessary data and verifies that the response status is 201 and the response JSON contains the correct data.
- testDeleteExistingABTest: Tests the deletion of an existing AB test. It sends a DELETE request and verifies that the response status is 204.
- testDeleteExistingNonDraftABTest: Tests the deletion of a non-draft AB test. It sends a DELETE request and verifies that the response status is 417 and the response JSON contains the correct error message.
- testDeleteNonExistingABTest: Tests the deletion of a non-existing AB test. It sends a DELETE request and verifies that the response status is 404.
- testFindABTestById: Tests finding an AB test by its ID. It sends a GET request and verifies that the response status is 200 and the response JSON contains the correct data.
- testFindABTestByName: Tests finding an AB test by its name. It sends a GET request and verifies that the response status is 200 and the response JSON contains the correct data.
- testFindNonExistingABTest: Tests finding a non-existing AB test. It sends a GET request and verifies that the response status is 404.
- testGetAllABTestsByAdmin: Tests retrieving all AB tests by an admin user. It sends a GET request and verifies that the response status is 200 and the response JSON contains the correct number of AB tests.
- testSearchABTestsByFields: Tests searching AB tests by various fields. It sends a GET request with search parameters and verifies that the response status is 200 and the response JSON contains the correct data.
- testPublishABTest: Tests publishing an AB test. It sends a POST request and verifies that the response status is 200 and the database contains the correct log entry.
- testPublishDraftABTest: Tests publishing a draft AB test. It sends a POST request and verifies that the response status is 422.
- testUpdateNonExistingABTest: Tests publishing a non-existing AB test. It sends a POST request and verifies that the response status is 422.
- testUpdateExistingABTest: Tests updating an existing AB test. It sends a PUT request with the necessary data and verifies that the response status is 200 and the response JSON contains the correct data.
- testUpdateNonExistingABTest: Tests updating a non-existing AB test. It sends a PUT request and verifies that the response status is 422.
- testUpdateExistingABTestWithEmptyValues: Tests updating an existing AB test with empty values. It sends a PUT request and verifies that the response status is 422 and the response JSON contains the correct error messages.
To run the tests, use the following command:
php artisan test
Make sure to set up your testing environment and database before running the tests.