From a9ad7c6771196425c88f72cd546abc0e54d00ed9 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 7 Feb 2023 09:37:36 +0000
Subject: [PATCH] fail safe unit test, fixes #2093

Closes #2093

Merge request studip/studip!1377
---
 .../unit/lib/classes/StudipFileloaderTest.php | 37 ++++++++++---------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/tests/unit/lib/classes/StudipFileloaderTest.php b/tests/unit/lib/classes/StudipFileloaderTest.php
index ec457939a37..1ffe6b572de 100644
--- a/tests/unit/lib/classes/StudipFileloaderTest.php
+++ b/tests/unit/lib/classes/StudipFileloaderTest.php
@@ -8,34 +8,37 @@
  * @copyright (c) Authors
  */
 
-class StudipFileloaderTestCase extends \Codeception\Test\Unit {
-
-    public function setUp(): void {
-        ArrayFileStream::set_filesystem(
-            [
-                'pathto' => [
-                    'config-1.php' => '<? $CONF = 17; '
-                    , 'config-2.php' => '<? $CONF = 17 + $offset; '
-                ]]);
-
-        if (!stream_wrapper_register("var", "ArrayFileStream")) {
-            new Exception("Failed to register protocol");
+class StudipFileloaderTestCase extends \Codeception\Test\Unit
+{
+    public function setUp(): void
+    {
+        ArrayFileStream::set_filesystem([
+            'pathto' => [
+                'config-1.php' => '<?php $CONF = 17; ',
+                'config-2.php' => '<?php $CONF = 17 + $offset; ',
+            ]
+        ]);
+
+        if (!stream_wrapper_register('var', 'ArrayFileStream')) {
+            new Exception('Failed to register protocol');
         }
     }
 
-    public function tearDown(): void {
-        stream_wrapper_unregister("var");
+    public function tearDown(): void
+    {
+        stream_wrapper_unregister('var');
     }
 
 
-    public function test_should_inject_vars() {
+    public function test_should_inject_vars()
+    {
         $container = [];
         StudipFileloader::load('var://pathto/config-1.php', $container);
         $this->assertEquals(['CONF' => 17], $container);
     }
 
-    public function test_should_inject_vars_twice() {
-
+    public function test_should_inject_vars_twice()
+    {
         foreach (range(1,2) as $i) {
             $container = [];
             StudipFileloader::load('var://pathto/config-1.php', $container);
-- 
GitLab