]> BookStack Code Mirror - bookstack/blobdiff - tests/TestCase.php
Lexical: Added tests to cover recent changes
[bookstack] / tests / TestCase.php
index c59f843e94bdd877c4e8601c6d214c1977405e40..0fb899ea99eebf419fa93f92732c24e0594606c6 100644 (file)
@@ -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) {