What’s the proper method of installing a plugin during unit testing?

Then there’s the Composer approach described here by Steve Grunwell, to load WooCommerce as a development dependency: $ composer require –dev –prefer-source woocommerce/woocommerce where he mentioned doing some composer.json adjustments, like moving WooCommerce under the vendor path: “extra”: { “installer-paths”: { “vendor/{$vendor}/{$name}”: [ “woocommerce/woocommerce” ] } } and include WooCommerce tests in the generated autoloader: … Read more

WP_UnitTestCase missing?

This class is defined in includes/testcase.php. If you checkout the entire repo, you should have it. To check out the entire repo, you should be running something along the lines of: svn co https://unit-tests.svn.wordpress.org/trunk wordpress-tests

Using wp_mail during an integration test

I was working on some tests for code that involved wp_mail() just the other day. I couldn’t find any docs on it either, but I took a look at the source of mock-mailer.php, and everything was rather simple. First, you should understand that WordPress always uses the $phpmailer global to hold an instance of the … Read more

Can I get at WordPress code from inside a Selenium test?

There are many ways to skin a cat and trying to use Selenium with WordPress CLI is new to me. Essentially, WordPress is ‘just’ a dynamic website using a SQL database with some themes and plugin files behind it. Selenium is designed as a frontend browser test tool so keep that in mind for a … Read more

Proper unit testing in WordPress

I think that what you are looking for would actually technically be called functional testing, integration testing, or acceptance testing. It sounds like you want to test the behavior of the front-end of your website (or the front-end behavior of a plugin or theme), not each unit of the code itself. You might use a … Read more

Developing, Testing and Releasing

There is a bit of personal philosophy that goes into a deployment workflow. It’s not an easy question to answer outright without knowing your experience with servers and version control, your operating system, hosting, client’s experience and tech culture, etc… Here’s a similar question that has a lot of explanation. For content deployment, you can … Read more

Testing hooks callback

Test in isolation When developing a plugin, the best way to test it is without loading the WordPress environment. If you write code that can be easily tested without WordPress, your code becomes better. Every component that is unit tested, should be tested in isolation: when you test a class, you only have to test … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)