Phpunit: PHPUnit\Framework\TestCase::__constructor marked as internal even though it's intended to be used

Created on 6 Dec 2019  ·  3Comments  ·  Source: sebastianbergmann/phpunit

| Q | A
| --------------------| ---------------
| PHPUnit version | 8.5.0
| PHP version | 7.3.12
| Installation Method | PHAR

Summary

Method PHPUnit\Framework\TestCase::__constructor is marked as internal with this message:

@internal This method is not covered by the backward compatibility promise for PHPUnit

Current behavior

Method is marked as internal, seemingly just to signal it not being covered by BC.

But it's not actually internal since it's intended to be used by the fast you extend TestCase in your own suites.

The usage of internal methods is reported by running Psalm on your tests:

ERROR: InternalMethod - tests/Xezilaires/Bridge/PhpSpreadsheet/RowIteratorTest.php:28:37 - The method PHPUnit\Framework\TestCase::__construct has been marked as internal
final class RowIteratorTest extends TestCase

How to reproduce

Run Psalm on your tests backed by PHPUnit 8.5.0.

Expected behavior

Method(s) which are intended to be used by the tests shouldn't be marked as internal.

typbug

All 3 comments

Just found another one:

ERROR: InternalMethod - tests/Xezilaires/SpreadsheetIteratorTest.php:123:30 - The method PHPUnit\Framework\MockObject\Builder\InvocationMocker::willReturn has been marked as internal
                    $mocker->willReturn($spec['return']);

I do not know where you get the idea that PHPUnit\Framework\TestCase::__constructor() is intended to be used in your own tests.

It's not used directly, but the ctor is invoked just by extending TestCase, no? So basically any test case out there is using an internal method by default.

Was this page helpful?
0 / 5 - 0 ratings