Automated tests for the smallest parts of code.

learn more… | top users | synonyms

0
votes
2answers
47 views

How to cancel Wordpress' action/filter when using OOP with anonymous callback

Most of the wordpress plugins I found is functions based, for example, the offical akismet plugin function akismet_init() { global $wpcom_api_key, $akismet_api_host, $akismet_api_port; // ...
1
vote
0answers
15 views

Theme unit test data Foreign fonts come in garbled on my machine

Having just tried out the Theme Unit Test Data from the WordPress.org Codex, I noticed that some of the body text doesn't import properly on my set up which is a Mac running Mavericks. The effect is ...
1
vote
0answers
28 views

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 ...
1
vote
1answer
35 views

WordPress function gives different results outside vs inside PHPUnit test

I've been working very hard to get PHPUnit to play nice with WordPress (with the help of this, this, this, this, and this), and I think I've gotten pretty close. The code I run directly before my ...
1
vote
1answer
27 views

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: ...
0
votes
0answers
26 views

Wordpress Unit Testing cleaning up hooks and filters

Using Wordpress' unit testing suite has been going quite well, and it's nice the WP_UnitTestCase takes care of cleaning up table data after each unit test. But one thing that doesn't seem to be ...
3
votes
1answer
345 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 ...
3
votes
1answer
149 views

Wordpress test environment on windows

I'm new to TDD and want to set up a test environment for my wordpress plugin. I was able to find a sample plugin from wp-cli with the very useful script. It was very easy to write the first test ...
4
votes
2answers
323 views

Where can I find documentation for the WP_UnitTestCase factory classes?

In recent versions WP_UnitTestCase has included a $factory property. For example: $post = $this->factory->post->create(); Where can I find documentation on this useful feature?
4
votes
4answers
652 views

How do I mock HTTP requests for PHPUnit?

I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both wp_remote_get and ...
2
votes
2answers
61 views

how to test a theme upgrade

Is there a way to test run a theme through the automatic updater? We have a theme where a version will introduce new functionality which might break existing themes. I would like to check previous ...
0
votes
2answers
114 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 ...
3
votes
2answers
127 views

struggling to set up WP tests

I want to contribute to a guys plugin (TimberWp). I'd like to do it with tests. his plugin has a test dir that looks just like the wp-cli scaffolded dir. all v standard. Iv'e managed to get as ...
5
votes
0answers
216 views

Can’t get the phpunit core test for WordPress to work [closed]

I’m trying to set up the test for the WordPress core to make sure that the plugin I’m developing doesn't break anything. But I’m having a problem which I really have no idea how to fix. I downloaded ...
1
vote
1answer
70 views

how to set context in Wordpress for unit testing

I have created a wordpress plugin which converts shortcodes to content based on the entry saved on the dataase: global $wpdb; $post_id = get_the_ID(); $post_content = get_the_content(); ...
8
votes
1answer
219 views

WordPress Themes and PHP unit

Is there any examples of using PHP unit tests with WordPress themes, seems a lot of blogs out there on the subject are out dated as the core unit tests are apart of trac, yet last night - I pulled ...
0
votes
2answers
509 views

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... ...
1
vote
0answers
18 views

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 ...
3
votes
1answer
392 views

Why Can't PHPUnit UnitTest My Wordpress Website

I have been researching this issue for days and although many people ask this question I never found a clear and concise answer. I am running: PHP Unit: Version 3.7.21 WordPress: Version 3.5.1 OS: ...
6
votes
1answer
176 views

How to write testable classes in Wordpress

I'm currently doing some modifications on the Wordpress plugin that I created in order to make it testable. The problem is I don't know which methods am I suppose to write tests for. I have methods ...
1
vote
1answer
127 views

Unit testing wordpress plugins with plugin options

I'm new with unit testing in Wordpress. I managed to setup the unit testing environment using PHP Unit and Wordpress tests but I am having trouble accessing the plugin options that I've set in the ...
2
votes
1answer
63 views

unit testing admin password

I'm writing up unit tests for my plugin and I need a logged in user to test, but I can't find the admin password anywhere. Does anybody know what the default admin password is? I'm extending the ...
2
votes
2answers
208 views

Plugin development with unit tests

One of the things that my plugin does is creates a number of SQL tables as part of a versioning function (that is run under the admin_init hook as I couldn't find a better wordpress way of doing ...
2
votes
1answer
48 views

Unit Testing a Plugin functionality with cron

I'm currently on the process of unit testing a plugin using the Wordpress unit testing framework. In one of the functions to be tested,it will send mails to users in a periodic time interval so it ...
4
votes
1answer
156 views

Can I simulate a user being logged in from a WP_UnitTestCase?

I have some logic in my code that's based on whether or not the user is logged in. How do I test it from my WP_UnitTestCase?
3
votes
1answer
346 views

WP_UnitTestCase missing?

I was looking at tests for wordpress and some, if not all the classes have WP_UnitTestCase but I cannot find the class, why do I care? I have downloaded The most up to date version of this from github ...