Articles of unit tests

Set up PHPUnit with WordPress: The WordPress tests are 3 – 4 years old; does it matter?

I’m trying to set up PHPUnit with WordPress, and the tutorial I found tells me to download this repository so that I can bootstrap the WordPress environment to run my tests. The only issue I have is that the repo was last changed 3 – 4 years ago, which is a long time. I have […]

How to do an unit test for the admin dashboard

I am trying to do unit test on codeception with wp-browser for a wordpress plugin based on a boilerplate. The problem that is in this line of code I initialize the class for admin only when is not an AJAX request and is is_admin(). So I have the problem that I do the test but […]

PHPUnit via WP-CLI: Warning: Cannot modify header information … bootstrap.php:68

I’m trying to setup unit tests for a plugin I am developing. I just followed the steps at… However, when I run phpunit I get the following… $ phpunit Installing… Running as single site… To run multisite, use -c tests/phpunit/multisite.xml Warning: Cannot modify header information – headers already sent by (output started at /private/tmp/wordpress-tests-lib/includes/bootstrap.php:68) […]

How to import Theme Unit Test on localhost

I am a total beginner with WP and struggle to import this xml file. Tools->Import->WordPress and here I am asked for Hostname, FTP Username, FTP Password and Connection Type. I am on local mashine… When I download the plugin and try to do it manually it is the same story. So how can I import […]

How exactly *does* unit testing work for themes?

As the majority of material on unit testing focuses on plugin development rather than theme development, I’ve hit a stumbling block when trying it out for myself. I’ve installed PHPUnit, grabbed the test suite from the WP repo, and configure it so that the tests run. What I haven’t quite figured out is how do […]

Installing WordPress Theme Unit Data

I’m following the “Building Themes from Scratch Using Underscores (2016)” tutorial on and at around 00:35 he suggests downloading the Theme Unit Test Data from WordPress. I’ve downloaded the xml file, but when I go to the dashboard of my WordPress site, then Tools –> Import –> WordPress, I’m prompted to install the WordPress […]

Error Testing create_empty_blog() via PHPUnit + Unit Tests

I have been reading up on TDD for a little while, and now have a multisite plugin to ‘test’ it out on.. At this stage I am a little unsure whether the error is within the Unit Tests, my tests, my plugin or my understanding. So a fair few points of failure there! On activation […]

Using My Own Classes On Wp Unit Tests

(I’m trying to solve style problems of code samples) I’m developing a theme but I have some classes which developed for this theme. I want to run unit tests on my theme. I’ve followed this steps: Checked out test repo to my root web folder: svn co wordpress-develop Copied my theme folder to wordpress-develop/src/wp-content/themes […]

WordPress Automatic Testing Probelm

After much trial and error. I’ve managed to get the automatic testing setup and running. I’m running a test on a plugin that has no code. It’s just the plugin header. Just to make sure everything is working with the phpunit tests. It’s on a brand new multipress install and there is no data besides […]

What make possible unit test plugins?

This is more a theory related question. I’m not looking at the practical ways to do this, as I can find plenty of example (official and not), which however does not explain how it is possible to properly create and run tests for elements of code that relies so much on the system (WordPress) and […]