diff --git a/src/Hook/BypassFinalHook.php b/src/Hook/BypassFinalHook.php new file mode 100644 index 0000000..0ea6476 --- /dev/null +++ b/src/Hook/BypassFinalHook.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Scc\PhpUnit\Hook; + +use DG\BypassFinals; +use PHPUnit\Runner\BeforeTestHook; + +/** + * @see https://tomasvotruba.com/blog/2019/03/28/how-to-mock-final-classes-in-phpunit/ + */ +final class BypassFinalHook implements BeforeTestHook +{ + public function executeBeforeTest(string $test): void + { + BypassFinals::enable(); + } +} diff --git a/src/Traits/ReflectionUnitTests.php b/src/Traits/ReflectionUnitTests.php index f6e43ba..c399484 100644 --- a/src/Traits/ReflectionUnitTests.php +++ b/src/Traits/ReflectionUnitTests.php @@ -11,7 +11,7 @@ declare(strict_types=1); * file that was distributed with this source code. */ -namespace Scc\PhpUnit; +namespace Scc\PhpUnit\Traits; /** * Trait ReflectionTrait.