Question | Answer |
---|---|
Infection version | 0.28.1 |
Test Framework version | PHPUnit 11.1-dev |
PHP version | 8.3.4 |
Platform | Fedora |
Github Repo | https://github.com/sebastianbergmann/phpunit |
The Finished
class has a public
method named test
.
Infection's PublicVisibility
mutator replaces public
and protected
and Infection then claims that this mutation survived, as can be seen in this screenshot:
However, when I perform this mutation manually ...
diff --git a/src/Event/Events/Test/Lifecycle/Finished.php b/src/Event/Events/Test/Lifecycle/Finished.php
index 72032cf71..ae75d35c1 100644
--- a/src/Event/Events/Test/Lifecycle/Finished.php
+++ b/src/Event/Events/Test/Lifecycle/Finished.php
@@ -37,7 +37,7 @@ public function telemetryInfo(): Telemetry\Info
return $this->telemetryInfo;
}
- public function test(): Code\Test
+ protected function test(): Code\Test
{
return $this->test;
}
... and try to run PHPUnit's test suite then I get this error:
$ ./phpunit --testsuite unit
PHPUnit 11.1-gb18d5f2fe3 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.4
Configuration: /usr/local/src/phpunit/phpunit.xml
.
An error occurred inside PHPUnit.
Message: Call to protected method PHPUnit\Event\Test\Finished::test() from scope PHPUnit\Runner\ResultCache\ResultCacheHandler
Location: /usr/local/src/phpunit/src/Runner/ResultCache/ResultCacheHandler.php:119
#0 /usr/local/src/phpunit/src/Runner/ResultCache/Subscriber/TestFinishedSubscriber.php(27): PHPUnit\Runner\ResultCache\ResultCacheHandler->testFinished()
#1 /usr/local/src/phpunit/src/Event/Dispatcher/DirectDispatcher.php(102): PHPUnit\Runner\ResultCache\TestFinishedSubscriber->notify()
#2 /usr/local/src/phpunit/src/Event/Dispatcher/DeferringDispatcher.php(45): PHPUnit\Event\DirectDispatcher->dispatch()
#3 /usr/local/src/phpunit/src/Event/Emitter/DispatchingEmitter.php(962): PHPUnit\Event\DeferringDispatcher->dispatch()
#4 /usr/local/src/phpunit/src/Framework/TestRunner.php(235): PHPUnit\Event\DispatchingEmitter->testFinished()
#5 /usr/local/src/phpunit/src/Framework/TestCase.php(337): PHPUnit\Framework\TestRunner->run()
#6 /usr/local/src/phpunit/src/Framework/TestSuite.php(369): PHPUnit\Framework\TestCase->run()
#7 /usr/local/src/phpunit/src/Framework/TestSuite.php(369): PHPUnit\Framework\TestSuite->run()
#8 /usr/local/src/phpunit/src/Framework/TestSuite.php(369): PHPUnit\Framework\TestSuite->run()
#9 /usr/local/src/phpunit/src/TextUI/TestRunner.php(62): PHPUnit\Framework\TestSuite->run()
#10 /usr/local/src/phpunit/src/TextUI/Application.php(200): PHPUnit\TextUI\TestRunner->run()
#11 /usr/local/src/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#12 {main}
The mutation causes an error in PHPUnit's test runner that is not specific to a single test. Maybe mutating the test framework's / test runner's code so that it no longer works is a very special case? :)
$ git clone [email protected]:sebastianbergmann/phpunit.git
$ cd phpunit
$ git show --oneline -s
b18d5f2fe3 (HEAD -> main, origin/main, origin/HEAD) Add tests
$ ./tools/composer install
$ ./tools/infection --version
Infection - PHP Mutation Testing Framework version 0.28.1
$ ./tools/infection --threads=max --ignore-msi-with-no-mutations --only-covered --logger-html=infection.html