The API backend to the UK Controller Plugin, provides the plugin with information such as dependency files, squawk allocations and user authentication.
The API is built on Laravel Framework and uses PHPUnit for tests.
A development environment using docker-compose
comes bundled with the source, to use it simply run docker-compose build
followed by docker-compose up
.
The development database binds to Port 3306 and can be connected to using the password provided in
the docker-compose.yml
.
composer install
.env.example
to .env
and fill in the APP_URL
and database credentialsAPP_KEY
for the application by running php artisan key:generate
php artisan migrate
to run database migrationsphp artisan db:seed
to see the database with test dataphp artisan user:create
php artisan user:create-admin
php artisan user:create-data-admin
php artisan token:create
php artisan tokens:delete-user
Assuming that you have run the migrations and seeded the database, running the tests is as simple as running the following command:
php artisan test
A separate database is available via the docker deployment on the same network to avoid losing the data contained in the migrations.
The same deployment steps outlined above should be carried out, but append --env=testing
to run them against the testing database.
Copy the environment file .env.testing.example
to .env.testing
to allow these values to be used when running the test suite.
The test suite will use the testing
environment via the APP_ENV
variable set within phpunit.xml
(the PHPUnit configuration).
In this instance, the phpunit command should be run from within the web
container so that the docker network is available:
docker exec -it web /bin/bash
This project uses PSR-12 for its formatting style. You can enforce these standards through most Code Editors, or, alternatively, StyleCI will run on every pull request.
Every pull request is also run through SonarCloud to check for code smells.