Skip to content

OlivierFL/Floch_Olivier_8_19062021

 
 

Repository files navigation

ToDoList

Maintainability Quality Gate Status Maintainability Rating

Project

Project 8 - Update and improve an existing project

Requirements

Mandatory :

  • PHP >= 8.0
  • Symfony CLI

Optional :

  • Make to use the Makefile and custom commands
  • Docker and Docker-compose for MySQL database and PhpMyAdmin containers

Unit Tests :

  • PHPUnit

Installation

  1. To get this project on your local machine, simply clone this repository :

    git clone [email protected]:OlivierFL/Floch_Olivier_8_19062021.git
  2. Install the dependencies :

  • composer install
  1. Environment configuration :

    To configure local dev environment, create a .env.local file at the root of the project.

    To configure database connection, override the DATABASE_URL env variable with your database credentials and database name, for example :

    DATABASE_URL="mysql://root:[email protected]:3306/todo?serverVersion=5.7"

    If you're using the MySQL Docker container, the config is :

    DATABASE_URL="mysql://root:[email protected]:3306/todo"
  2. After configuring the database connection, run bin/console doctrine:database:create to create the database, then bin/console doctrine:schema:create to create database tables.

  3. Then run bin/console doctrine:fixtures:load to load the example data into the database. If you're using Docker, PhpMyAdmin is available on localhost:8080 (user : root, password : admin).

  4. By default

7.Start the Symfony server with symfony server:start -d.

The base url for the API is : localhost:8000.

Usage

List of useful commands to use the project :

  • symfony server:start to start the Symfony server
  • symfony server:stop to stop the Symfony server

Commands to use with Docker and Make (commands are available in Makefile at the root of the project) :

  • make up to start Docker stack (MySQL and PhpMyAdmin) and Symfony server
  • make install to run installation process automatically (manual environment configuration is needed before running this command)
  • make tests to run all PHPUnit tests, the database is reset before running the tests (see tests) to know how to configure the environment to run the tests
  • make tests-coverage to run all PHPUnit tests with code coverage
  • make tests-functional to run only functional PHPUnit tests
  • make tests-entity to run only PHPUnit unit tests for entities
  • make tests-no-reset to run all PHPUnit tests, without resetting the database
  • make down to stop Docker stack (MySQL and PhpMyAdmin) and Symfony server

Sample data

In order to have a fully functional application, the fixtures contains :

  • 2 Users with different roles :

    • an Admin user (with ROLE_ADMIN role) with [email protected] email, and admin1234 password.

    • a simple User (with ROLE_USER role) with [email protected] email, and user1234 password.

  • A default list of Tasks (36 items).

  • 10 Tasks without an author. By default, and to show how this issue is fixed by this pull request, 10 Tasks do not have a User. To fix this, use the Console Command : bin/console task:set-user. This command creates an Anonymous User if it does not exist in database, and links this user to the Tasks without an author.

  • A default list of Users (26 items). If the above Console Command has been run, an Anonymous User has been added in the database (27 items).

Third party libraries

Third party libraries used in this project :

Docker (optional)

This project uses Docker for MySQL database and PhpMyAdmin.

The stack is composed of 2 containers :

  • mysql
  • phpMyAdmin

The configuration is available in the docker-compose.yaml.

Tests

PhpUnit is used to run the tests.

Before running the tests, and to have a separate database for tests, create a .env.test.local file at the root of the project.

In this file, add a DATABASE_URL env variable to change the database name, for example :

DATABASE_URL="mysql://root:[email protected]:3306/todo_tests"

Then, run these commands in a terminal to create the database used for the tests, and load the fixtures in the test's database :

APP_ENV=test symfony console doctrine:database:create
APP_ENV=test symfony console doctrine:schema:create
APP_ENV=test symfony console doctrine:fixtures:load -n

When using the make tests command from the Makefile, these commands will be run automatically.

Finally, in a terminal, at the root of the project, run APP_ENV=test symfony php bin/phpunit --colors or make tests.

It's possible to generate code coverage report by running APP_ENV=test symfony php bin/phpunit --colors --coverage-html tests-coverage or make tests-coverage. The tests-coverage directory will be created, and the report will be available in a browser by opening the index.html file from this directory.

Code quality

Links to code quality tools used for this project:

Codeclimate : https://codeclimate.com/github/OlivierFL/Floch_Olivier_8_19062021

SonarCloud : https://sonarcloud.io/dashboard?id=OlivierFL_Floch_Olivier_8_19062021

Releases

No releases published

Packages

No packages published

Languages

  • HTML 88.0%
  • PHP 10.0%
  • Twig 1.2%
  • CSS 0.3%
  • Makefile 0.2%
  • JavaScript 0.2%
  • Shell 0.1%