Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

rzajac/php-test-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Test helper classes.

Unit testing helper.

What does it help with?

  • Load database fixtures (sql).
  • Load file fixtures (json, txt, php).
  • Tests where you interact with database.
  • Database helper methods see database interface.

Supported databases.

  • MySQL

Install.

{
    "require": {
        "rzajac/php-test-helper": "^2.0"
    }
}

Run unit tests.

Yes! The package has it's own unit tests.

$ vendor/bin/phpunit --coverage-html=./coverage 

Setup database for unit tests.

MySQL.

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.

Loading time zone tables.

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p

License.

Apache License Version 2.0

About

Unit testing helper classes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages