RecursiveDirectoryIterator Error on phpunit with wordpress

I’m trying to do unit test of wordpress plugin by phpunit(ver 4.2.6).
But when I run phpunit command, this error occurs:

1) SampleTest::testSample
UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/wordpress/wp-content/uploads): failed to open dir: No such file or directory

Read More

/private/tmp/wordpress-tests-lib/includes/testcase.php:407

/private/tmp/wordpress-tests-lib/includes/testcase.php:425

/private/tmp/wordpress-tests-lib/includes/testcase.php:26

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

SampleTest file is just like this.

class SampleTest extends WP_UnitTestCase {

    function testSample() {
        $this->assertTrue( true );
    }
}

I have no idea what is wrong. Have anyone experienced this problem?

Related posts

Leave a Reply

1 comment

  1. I had the same issue and I manually created the uploads directory and then the tests ran successfully.

    mkdir /tmp/wordpress/wp-content/uploads

    Seems like the “uploads” folder was just missing.