This library allows for easy testing of WordPress plugins, themes widgets, libraries. You name it.
You need to have access to a database server to make use of this library.
Clone this repo into your tests directory
$ cd my-project/
$ cd tests/
$ git clone https://github.com/mekom/WP-CoreTestLibCopy the config sample into the root of your tests directory.
note: Your config file should be besides the WP-CoreTestLib directory, and not inside it.
my-project/
tests/
WP-CoreTestLib/
wp-test-config-sample.php
wp-test-config.php
$ cd my-project/tests/
$ cp WP-CoreTestLib/wp-test-config-sample.php wp-test-config.phpSupply the correct settings for database access to the my-project/tests/wp-test-config.php file. (Remember: Using 127.0.0.1 instead of localhost might be preferable)
Include the WP-CoreTestLib/bootstrap.php file from your PHPUnit bootstrap file.
my-project/tests/bootstrap.php
require __DIR__ . "/WP-CoreTestLib/bootstrap.php";Great! That should be it. You now be able to test WordPress things, and have access to some special wordpress testing functions. You can google the "wordpress testing library" to find out which these are.
But I'll list some of them for you
###WP_UnitTestCase This is the class you should extend instead of `PHPUnitTestCase