[hook] Add BypassFinalHook
This commit is contained in:
27
src/Hook/BypassFinalHook.php
Normal file
27
src/Hook/BypassFinalHook.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user