| Total Complexity | 7 | 
| Total Lines | 36 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 12 | abstract class UnitTestCase extends BaseTestCase  | 
            ||
| 13 | { | 
            ||
| 14 | protected static bool $hasSetUpKernel = false;  | 
            ||
| 15 | |||
| 16 | protected static bool $needsKernel = false;  | 
            ||
| 17 | protected static bool $needsConfig = false;  | 
            ||
| 18 | |||
| 19 | protected static function needsKernel(): void  | 
            ||
| 20 |     { | 
            ||
| 21 |         if (! self::$hasSetUpKernel) { | 
            ||
| 22 | self::setupKernel();  | 
            ||
| 23 | }  | 
            ||
| 24 | }  | 
            ||
| 25 | |||
| 26 | public static function setUpBeforeClass(): void  | 
            ||
| 27 |     { | 
            ||
| 28 |         if (static::$needsKernel) { | 
            ||
| 29 | self::needsKernel();  | 
            ||
| 30 | }  | 
            ||
| 31 | |||
| 32 |         if (static::$needsConfig) { | 
            ||
| 33 | self::mockConfig();  | 
            ||
| 34 | }  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | protected static function setupKernel(): void  | 
            ||
| 38 |     { | 
            ||
| 39 | HydeKernel::setInstance(new HydeKernel());  | 
            ||
| 40 | self::$hasSetUpKernel = true;  | 
            ||
| 41 | }  | 
            ||
| 42 | |||
| 43 | protected static function mockConfig(array $items = []): void  | 
            ||
| 44 |     { | 
            ||
| 45 |         app()->bind('config', fn (): Repository => new Repository($items)); | 
            ||
| 46 | |||
| 47 |         Config::swap(app('config')); | 
            ||
| 48 | }  | 
            ||
| 50 |