X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/cc10d1ddfc652f6bcf3bbf61d5ec2e2861394c03..refs/pull/5676/head:/tests/TestCase.php diff --git a/tests/TestCase.php b/tests/TestCase.php index c59f843e9..0fb899ea9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -118,7 +118,7 @@ abstract class TestCase extends BaseTestCase * Database config is juggled so the value can be restored when * parallel testing are used, where multiple databases exist. */ - protected function runWithEnv(string $name, $value, callable $callback) + protected function runWithEnv(string $name, $value, callable $callback, bool $handleDatabase = true) { Env::disablePutenv(); $originalVal = $_SERVER[$name] ?? null; @@ -132,13 +132,17 @@ abstract class TestCase extends BaseTestCase $database = config('database.connections.mysql_testing.database'); $this->refreshApplication(); - DB::purge(); - config()->set('database.connections.mysql_testing.database', $database); - DB::beginTransaction(); + if ($handleDatabase) { + DB::purge(); + config()->set('database.connections.mysql_testing.database', $database); + DB::beginTransaction(); + } $callback(); - DB::rollBack(); + if ($handleDatabase) { + DB::rollBack(); + } if (is_null($originalVal)) { unset($_SERVER[$name]); @@ -248,8 +252,8 @@ abstract class TestCase extends BaseTestCase $detailsToCheck = ['type' => $type]; if ($entity) { - $detailsToCheck['entity_type'] = $entity->getMorphClass(); - $detailsToCheck['entity_id'] = $entity->id; + $detailsToCheck['loggable_type'] = $entity->getMorphClass(); + $detailsToCheck['loggable_id'] = $entity->id; } if ($detail) {