Automated tests for the smallest parts of code.

learn more… | top users | synonyms

4
votes
2answers
114 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
305 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
56 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
31 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 ...
2
votes
2answers
95 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
131 views

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

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
50 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(); ...
7
votes
1answer
168 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
244 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
12 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
277 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
162 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
105 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
52 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
176 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 ...
1
vote
0answers
29 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 ...
3
votes
1answer
116 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
258 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 ...