“Fatal error: Class ‘PHPUnit_Framework_TestCase’ not found”

09. February 2017 Note ,

When I ran phpunit for my WordPress plugin, I got an error like following.

$ phpunit 
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /private/tmp/wordpress-tests-lib/includes/testcase.php on line 15

Apparently PHPUnit 6 no longer seems to support PHPUnit_Framework_TestCase.

So I had to update my plugin like following.

$ composer require phpunit/phpunit:5.6
$ composer install

Then run phpunit, it works fine.

$ vendor/bin/phpunit

Finally, I updated .travis.yml like following.

    - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
    - composer install
    - vendor/bin/phpunit

Ah, I have to update other plugins too.

3 thoughts on ““Fatal error: Class ‘PHPUnit_Framework_TestCase’ not found””

Leave a Reply

Your email address will not be published. Required fields are marked *