Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Improved WordPress tests (moved to core)
PHP
Branch: master
Pull request Compare This branch is 13 commits ahead, 1 commit behind nb:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
mu-plugins
src/Queensbridge
tests
.gitignore
README.md
build.xml
composer.json
composer.lock
phpunit.xml

README.md

WordPress Tests

This is a library for writing tests for plugins, themes and sites.

Unit tests

The UnitTestCase class is used just like the normal PHPUnit_Framework_TestCase class. Right it is basically just a shortcut.

Integration tests

The IntegrationTestCase class allows you to test against and use WordPress functions in your tests.

class SinglePageTest extends IntegrationTestCase
{
    public function testSingle()
    {
        $this->visit(get_permalink(1));
        $this->assertTrue(is_single());
        $this->assertTrue(have_posts());
    }
}

When doing integration tests it's possible to tell the bootstrap-script to download WordPress and to install it.

Acceptance tests

The AcceptanceTestCase class allows you to test the output of your site.

class WikipediaSearchTest extends AcceptanceTestCase
{
    public function testWithoutJavascript()
    {
        $this->visit('http://en.wikipedia.org/wiki/Main_Page');
        $this->assertStatusCodeEquals(200);

        $this->fillIn('search', 'Stockholm');
        $this->clickOn('searchButton');
        $this->assertStatusCodeEquals(200);
        $this->assertPageHasContent('Stockholm');

        $this->clickLink('Main page');
        $this->assertStatusCodeEquals(200);
    }
}
Something went wrong with that request. Please try again.