- Tests: PHPUnit + code coverage >= 80
- Checks: PHPMD, PHP_CodeSniffer
Clone the app and cd into the directory
$ composer install
$ docker-compose build
$ docker-compose up
Subsequently, if you run into permission issues trying to start the app, add sudo to the docker-compose build:
$ sudo docker-compose build
Open a new terminal and do this:
$ docker-compose exec app php bin/console doctrine:database:drop --force
$ docker-compose exec app php bin/console doctrine:database:create
$ docker-compose exec app php bin/console doctrine:migrations:migrate
$ docker-compose exec app php bin/console doctrine:fixtures:load
Admin details:
username: admin
password: adminpassword
Visit http://localhost:8000/
The REST API for the user entity is at:
/users
It is secured with basic HTTP Authentication. The admin details would work both on the web login form and the API basic auth.
Create user:
Method: POST
Route: /users
Example body:
{
"name": "Noob Saibot",
"username": "Noob",
"role": "PAGE_2",
"password": "noobpassword"
}
Get users:
Method: GET
Route: /users
Get user:
Method; GET
Route: /users/{id}
# Example:
/users/4
Update user:
Method: PUT
Route: /users/{id}
Example body:
{
"name": "Noob Saibot",
"username": "Noob",
"role": "PAGE_2",
"password": "noobpassword"
}
# Example:
/users/4
Body:
{
"name": "Noob Saibot",
"username": "Noob",
"role": "PAGE_2",
"password": "noobpassword"
}
Delete user:
Method: DELETE
Route: /users/{id}
# Example:
/users/4
I added am home page and navigation to ease the navigation between pages.
Root page: /
PAGE_1 : /page/1
PAGE_2 : /page/2
Create test database:
$ docker-compose exec app php bin/console doctrine:database:create --env test
Migrate the tes database:
$docker-compose exec app php bin/console doctrine:migrations:migrate --env test
Seed the test database:
$ docker-compose exec app php bin/console doctrine:fixtures:load --env test
Run tests:
$ docker-compose exec -u 1000 app php bin/phpunit
Check test coverage:
$ docker-compose exec app phpdbg -qrr ./vendor/bin/phpunit --coverage-text