Phpunit: Fatal error: PharIo\Manifest\ApplicationTest::setUp()

Created on 8 Jan 2020  路  1Comment  路  Source: sebastianbergmann/phpunit

| 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\FrameworkTestCase::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

Most helpful comment

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).

>All comments

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).

Was this page helpful?
0 / 5 - 0 ratings