Skip to main content

Questions tagged [unit-tests]

Automated tests for the smallest parts of code.

Filter by
Sorted by
Tagged with
44 votes
1 answer
13k views

Testing hooks callback

I'm developing a plugin using TDD and one thing that i completely fail to test are... hooks. I mean OK, i can test hook callback, but how could I test if a hook actually trigger (both custom hooks ...
Ionut Staicu's user avatar
7 votes
1 answer
1k views

Unit tests - Dealing with dependencies

This might be seen as a corollary of Testing hooks callback. The issue: I want to test a class which creates a new instance of a My_Notice class defined outside the plugin (let's call it the "Main ...
Andrea Sciamanna's user avatar
5 votes
1 answer
3k views

PHPUnit testing WordPress Plugin

Using answers on this site and from other resources, I have started writing my next plugin using PHPUnit tests and the WordPress test environment. Distilling down what I have in my plugin's bootstrap....
Matthew Bakaitis's user avatar
4 votes
2 answers
3k views

Implement phpunit testing on a plugin

I've just finished writing a WordPress plugin implementing shortcode tag based autocompletion based on values retrieved from a database given an id set on a cookie. The plugin has a variety of ...
NotGaeL's user avatar
  • 145
3 votes
1 answer
3k views

How to properly test a method that is called by an action hook

The constructor in my class adds an action to the 'init' action hook: class My_Custom_Post_Type { function __construct( $type ) { $this->type = $type; add_action( 'init', ...
Simon Cossar's user avatar
1 vote
2 answers
2k views

PHPUnit test plugin activation

I'm trying to test if my plugin activates properly with PHPUnit. I have used boilerplate structure generated on this site and added this test: class PluginTest extends WP_UnitTestCase { function ...
GeekDaddy's user avatar
  • 125
0 votes
2 answers
156 views

Installing WordPress Theme Unit Data

I'm following the "Building Themes from Scratch Using Underscores (2016)" tutorial on Lynda.com and at around 00:35 he suggests downloading the Theme Unit Test Data from WordPress. I've downloaded the ...
HappyHands31's user avatar