<?php class TestCase { private $num; private function yesOrNo() { return false; } public function runBare() { // simulating https://github.com/sebastianbergmann/phpunit/blob/9.1.5/src/Framework/TestCase.php#L1035 $this->doThePostConditionHook(); printf('We did %d tests', $this->num); } } trait ImmaExtendThis { /** * @postCondition */ protected function doThePostConditionHook() { echo '' . PHP_EOL; $this->num++; } private function brutalNumWorkaround() { (new ReflectionProperty(TestCase::class, 'num'))->setAccessible(true); } } class MyTest extends TestCase { use ImmaExtendThis; // ... } $my = new MyTest(); $my->runBare();
You have javascript disabled. You will not be able to edit any code.