Michael Lewis
Michael Lewis

Reputation: 4302

PHPUnit 3.4.15, PHP 5.2.6, and the WordPress Core Tests - Will this even work?

Let me cut to the chase. I'm trying to get the WordPress core tests to run, and they won't. I'm not sure if its even possible with my versions...

Here's what I've done so far: I created a very simple test in test_unit.php:

require_once ('PHPUnit\Framework.php');
class SimpleTest extends PHPUnit_Framework_TestCase
{
    public function testSomething()
    {
        $this->assertEquals(true, false);
    }
}

I run phpunit test_unit.php and it works (1 test, 1 assertion, 1 failure).

I still have some confusion about how PHPUnit is included, and I think someone said it changed to an autoloader of some kind in a newer version.

When I go to the wordpress tests folder, the directions say just run phpunit in that dir. This does not work. I've tried targeting specific files, using --configuration and --bootstrap flags to target those files specifically, and all that happens is the same thing: It gives me 1 blank line, and then returns to the command prompt.

Is there a specific file I need to include somewhere to get the WP test to run? A more important question: Will the WP tests even run w/ my outdated version of PHPUnit?

Your help is greatly appreciated!

Upvotes: 1

Views: 366

Answers (1)

Darren Cook
Darren Cook

Reputation: 28913

Try running phpunit from the parent directory of tests/. There is a clue in the docs where it says you can run a specific test with:

phpunit tests/actions.php

I.e. it expects tests to be a sub-directory.

(The docs say "Running phpunit in the same directory as the tests/ directory", which is a bit confusing isn't it, but is clearly different from "Running phpunit in the tests/ directory" The readme for the unit tests is a bit clearer.)

Upvotes: 2

Related Questions