简体   繁体   中英

PHPUnit on MAMP - throwing a fatal error

I am attempting to get phpUnit to function properly with MAMP on OS High Sierra and when trying to run a simple test it throws

"Fatal error: require_once(): Failed opening required 'PHPUnit/Framework/TestCase.php'

I've looked at several StackOverflow articles and they suggest changing it to "autoload.php"

that then throws...

"Failed opening required 'PHPUnit/Autoload.php'"

This is on Zend Framework 1 with PHP 7.2.

If you use Composer to install the PHPUnit, make sure you run it like this:

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/EmailTest

Or include vendor/autoload.php in your phpunit.xml like this:

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php"
>

See the docs .

The issue was the version of the framework. 1.8 is just not going to work. Phpunit works just fine with a 3.0.3 Skeleton. I'm going to research migrating the codebase to 3.0.3

Thanks for you help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM