-
Notifications
You must be signed in to change notification settings - Fork 336
Setting up testing database
This page will guide you to setup your testing database to be able to run PHPUnit, for development.
Make sure you have already installed timegrid and updated composer packages with --dev
parameter.
From your command-line, access to the mysql prompt.
mysql -u root -p
Once into the MySQL console
-- Create a database called `testing_timegrid`:
CREATE DATABASE testing_timegrid;
-- Create a user with the same name:
CREATE USER 'testing_timegrid'@'localhost' IDENTIFIED BY 'testing_timegrid';
-- Grant all permissions:
GRANT ALL PRIVILEGES ON `testing_timegrid`.* TO 'testing_timegrid'@'localhost';
Logout from mysql prompt
Ctrl + D
From your command-line, run the migrations:
php artisan migrate --database=testing
You should be ready to run unit tests with phpunit:
vendor/bin/phpunit
You will find the current test coverage status on CodeClimate
You may run:
php -d xdebug.profiler_enable=on vendor/bin/phpunit --coverage-html build/coverage --testdox-html build/testdox.html
Or enable xdebug and the logging
directive on phpunit.xml
The reports will be generated on the build/
directory.
If it seems like the environment is incorrect when you run tests. Before running them, make sure your config is not cached:
php artisan config:clear
Due to random generated data, some test cases may randomly fail.
Follows a list of failures that can be retried and get them pass.
1) ManagerBusinessServiceControllerTest::it_shows_the_business_service_page_for_management
1) ManagerBusinessServiceControllerTest::it_shows_the_business_service_edit_page_for_management
1) SeedingUnitTest::it_creates_a_demo_scenario
Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
1) UserAgendaControllerTest::it_takes_a_reservation_with_timeslot_on_shifted_timezone
1) ManagerSearchControllerTest::it_finds_an_appointment_by_code
1) UserContactControllerTest::it_can_change_nin_of_a_contact
They are, of course, marked for improvement on either the test or production code to handle those annoying border scenarios.
alariva