[hook] Add BypassFinalHook

This commit is contained in:
2022-10-16 08:12:05 +02:00
parent 7243a80807
commit b230172bde
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/*
* This file is part of the SCC CRM project.
* (c) <SCC> <crm@scc.fr>
*
* 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();
}
}

View File

@@ -11,7 +11,7 @@ declare(strict_types=1);
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Scc\PhpUnit; namespace Scc\PhpUnit\Traits;
/** /**
* Trait ReflectionTrait. * Trait ReflectionTrait.