| Conditions | 5 |
| Paths | 6 |
| Total Lines | 26 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public static function _resetDatabase(): void |
||
| 20 | { |
||
| 21 | if (DatabaseResetter::hasBeenReset()) { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | |||
| 25 | if (!\is_subclass_of(static::class, KernelTestCase::class)) { |
||
| 26 | throw new \RuntimeException(\sprintf('The "%s" trait can only be used on TestCases that extend "%s".', __TRAIT__, KernelTestCase::class)); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($isDAMADoctrineTestBundleEnabled = DatabaseResetter::isDAMADoctrineTestBundleEnabled()) { |
||
| 30 | // disable static connections for this operation |
||
| 31 | StaticDriver::setKeepStaticConnections(false); |
||
| 32 | } |
||
| 33 | |||
| 34 | $kernel = static::createKernel(); |
||
| 35 | $kernel->boot(); |
||
| 36 | |||
| 37 | DatabaseResetter::resetDatabase($kernel); |
||
| 38 | |||
| 39 | if ($isDAMADoctrineTestBundleEnabled) { |
||
| 40 | // re-enable static connections |
||
| 41 | StaticDriver::setKeepStaticConnections(true); |
||
| 42 | } |
||
| 43 | |||
| 44 | $kernel->shutdown(); |
||
| 45 | } |
||
| 70 |