“Fatal error: Class ‘PHPUnit_Framework_TestCase’ not found”
When I ran phpunit
for my WordPress plugin, I got an error like following.
$ phpunit Installing... 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.
before_script: - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION - composer install script: - vendor/bin/phpunit
Ah, I have to update other plugins too.
I noticed that even the latest trunk, https://develop.svn.wordpress.org/trunk/tests/phpunit/includes/, doesn’t support PHPUnit6 yet so this error was proving to be a challenge. Thanks for this work-around
Isn’t there any other solution? What the name of the new class?
PHPUnit Framework for WordPress will be updated on next version.
You can wait it.
https://core.trac.wordpress.org/ticket/39822