Unit testing helper.
- Load database fixtures (
sql
). - Load file fixtures (
json
,txt
,php
). - Tests where you interact with database.
- Database helper methods see database interface.
- MySQL
{
"require": {
"rzajac/php-test-helper": "^2.0"
}
}
Yes! The package has it's own unit tests.
$ vendor/bin/phpunit --coverage-html=./coverage
Create test users and database tables:
CREATE DATABASE testHelper1 DEFAULT CHARACTER SET = 'utf8' DEFAULT COLLATE = 'utf8_general_ci';
CREATE DATABASE testHelper2 DEFAULT CHARACTER SET = 'utf8' DEFAULT COLLATE = 'utf8_general_ci';
CREATE USER 'testUser'@'localhost' IDENTIFIED BY 'testUserPass';
CREATE USER 'testUser'@'%' IDENTIFIED BY 'testUserPass';
GRANT ALL ON `testHelper1`.* TO 'testUser'@'localhost';
GRANT ALL ON `testHelper2`.* TO 'testUser'@'localhost';
GRANT ALL ON `testHelper1`.* TO 'testUser'@'%';
GRANT ALL ON `testHelper2`.* TO 'testUser'@'%';
FLUSH PRIVILEGES;
Run tests:
$ vendor/bin/phpunit
When you have XDebug enabled running unit tests creates coverage report in coverage
directory.
$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
Apache License Version 2.0