How can I link tests to GitHub issues?

I don’t know of a library, but you could probably build one using TracTickets as a guide and using GitHub’s API. I’m actually answering to say don’t do this. WordPress actually no longer uses this method of skipping tests. See ticket #30284. I quote from there: Our previous convention was to write unit tests to … Read more

How to do an unit test for the admin dashboard

There are basically three options: Load that file with the admin-side code on-the-fly in setUp() or setUpBeforeClass(), so it will be loaded when those tests run. Load that file before the test suite is loaded and run, like in a bootstrap.php file or something, so it will be loaded for all the tests. Separate your … Read more

Write integration test for rest_pre_serve_request

The question actually has nothing specific to wordpress, but maybe it is worth answering. There is simply no code of your own in that sample that can be/is worth testing, therefor there isn’t much to unit test. Lets look at the details. add_filter is integration with core code, remove_filter is integration with core code and … Read more

Extending WP_UnitTestCase without any Tests

You just need to define the MZMBO_UnitTestCase class as abstract: abstract class MZMBO_UnitTestCase extends WP_UnitTestCase { public function el($message){ file_put_contents(‘./log_’.date(“j.n.Y”).’.log’, $message, FILE_APPEND); } }

What is the best way to create a factory for unit test objects?

If I undertsand correctly, what you are searching for is a good library for creating stubs and mocks. If you use PHPUnit, it has a features for that. See https://phpunit.de/manual/current/en/test-doubles.html#test-doubles For example, let’s assume you have a class like this: namespace MyApp; class MyCustomUser { public function __construct(\WP_User $user) { $this->user = $user; } public … Read more

unit testing admin password

The password is … password. You can see that in includes/install.php: wp_install( WP_TESTS_TITLE, ‘admin’, WP_TESTS_EMAIL, true, null, ‘password’ ); The last parameter is the admin password.