Error PHPUnit and PHPStorm ... ResultPrinter.php

Whenever I run phpunit tests from PHPStorm, I get an error. I have provided more details below. I am not sure where I skipped the setup setup.

My setting

  • Ubuntu
  • PHPStorm 8.0.1
  • PHPUnit 4.3.4

Additional Information:

PHPUnit.phar is located in /usr/local/bin/phpunit.phar . I set the PHPUnit path directly to PHPStorm. Tests run with bash without any problems. I also installed the phpunit.xml configuration file in PHPUnit, which is at the root of my project. The phpunit.xml file tells phpunit to load the autoload.php linker autoload.php .

PHPUnit output:

 /usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml Testing started at 10:33 AM ... PHPUnit 4.3.4 by Sebastian Bergmann. Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545 PHP Stack trace: PHP 1. {main}() /tmp/ide-phpunit.php:0 PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500 PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243 PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186 PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423 PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703 PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703 PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771 PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760 PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378 Process finished with exit code 255 

I searched Google and could not find a similar problem. I appreciate any help!

EDIT

Here is my phpunit.xml file. PHPStorm uses this as the "Use Alternate Configuration File"

 <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" colors="true" bootstrap="./vendor/autoload.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" > <testsuites> <testsuite name="Application Test Suite"> <directory>./tests/</directory> </testsuite> </testsuites> </phpunit> 
+6
source share
5 answers

I will answer my question if someone else comes across this problem.

The problem was the startup of PHPUnit through the composer and the use of phpunit.phar. As soon as I removed the phpunit dependency on the composer, PHPStorm was able to successfully complete all my tests.

+4
source

This is a startup problem. When you download the application for the test suite, you must initialize your autoloader, which does not seem to happen because something is not found. The easiest way is to use Composer to manage your PHPUnit dependency and automatically load your classes using the autoload directive. See section psr-4 in the documentation .

Then, in the PhpStorm PHPUnit configuration window, select Use custom autoloader and specify the path to your vendor/autoload.php script.

+11
source

The problem is not that you automatically download phpunit through the composer, but in the composer you are using the old version of phpUnit. In my case, instead of using 4.0.0, I upgraded to 4.6. *.

+3
source

Sometimes a better image ...

enter image description here

As you can see, you can also use the phpunit.phar file.

+1
source

I had the same problem with the composer and I had a problem with .phar. Today I just realized the forehead slap , it was caused by installing phpunit through the composer and then not reindexing the provider folder.

I did not find that I had this problem before when installing new packages with the composer, but for some reason when installing phpunit it did not reindex the provider folder, causing inconsistencies.

Reindex, everything is working fine.

0
source

Source: https://habr.com/ru/post/977548/


All Articles