PHP7 'phpunit' is not recognized as an internal or external command,
U:\Webpages\thecanadianhosting.co\app>composer test
> phpunit
'phpunit' is not recognized as an internal or external command,
operable program or batch file.
Script phpunit handling the test event returned with error code 1
Solution for PHP7 with Composer
composer require --dev phpunit/phpunit ^7
Solution for PHP7 without Composer
Downloads https://phar.phpunit.de/phpunit-7.phar
Save as "phpunit"
Run as ./phpunit
Hard solution
If the above don't work and you have recently upgraded from PHP5 to PHP7, the best solution in my opinion is to delete your composer.lock file, update your composer.json to have phpunit 7, then run composer install again for a fresh vendor install to the latest.
More problems after upgrade
U:\app>composer test
> phpunit
Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in U:\app\tests\Functional\BaseTestCase.php on line 16
Error: Class 'PHPUnit_Framework_TestCase' not found in U:\app\tests\Functional\BaseTestCase.php on line 16
Solution
After updating phpunit to version 6 or greater released on 2017-02-03 you will need to rename \PHPUnit_Framework_TestCase
to \PHPUnit\Framework\TestCase
Possible error: Undefined index: HTTP_HOST
There were 6 errors:
1) Tests\Functional\CreateAccountTest::testLoginView
Script phpunit handling the test event returned with error code 2
Undefined index: HTTP_HOST
(...)
Solution
Add php server name in phpunit.xml like so :
Recent Comments