sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.69k stars 2.2k forks source link

Fatal error: PharIo\Manifest\ApplicationTest::setUp() #4010

Closed unlikenesses closed 4 years ago

unlikenesses commented 4 years ago
Q A
PHPUnit version 8.5.1
PHP version 7.3.12
Installation Method Composer

Summary

After installing PhpUnit with

composer require --dev phpunit/phpunit ^8

and running

vendor/bin/phpunit

the following error occurs:

Fatal error: Declaration of PharIo\Manifest\ApplicationTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void in /path/vendor/phar-io/manifest/tests/values/ApplicationTest.php on line 44

My phpunit.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
         colors="true">
    <testsuites>
        <testsuite name="test">
            <directory>./</directory>
        </testsuite>
    </testsuites>
</phpunit>

This looks like the same issue as https://github.com/sebastianbergmann/phpunit/issues/3757

sebastianbergmann commented 4 years ago

Simply change <directory>./</directory> to <directory>tests</directory>.

With <directory>./</directory> you instruct PHPUnit to look for tests in all files that have a .php suffix and are located in . and its sub-directories (recursively). This includes the vendor directory which contains the sources for PHPUnit itself as well as its dependencies -- including tests. You do not want this (nobody wants this).