diff --git a/tests/TestFileHelper.php b/tests/TestFileHelper.php
new file mode 100644
index 0000000000000000000000000000000000000000..168514afe3a34d0ea163930217b11b3993b0ac31
--- /dev/null
+++ b/tests/TestFileHelper.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Tests;
+
+use PHPUnit\Framework\Assert;
+use Symfony\Component\Filesystem\Filesystem;
+
+class TestFileHelper
+{
+    private const LEGACY_DIRECTORY = __DIR__ . '/../legacy';
+
+    public static function createLegacyDirectoryIfNecessary(Assert $testCase): void
+    {
+        $fileSystem = new Filesystem();
+        if (!$fileSystem->exists(self::LEGACY_DIRECTORY)) {
+            $fileSystem->mkdir(self::LEGACY_DIRECTORY, 0644);
+        }
+        $testCase->assertTrue(
+            $fileSystem->exists(self::LEGACY_DIRECTORY),
+            'The directory \'' . self::LEGACY_DIRECTORY . '\' should exists'
+        );
+    }
+}
diff --git a/tests/functional/CapsuleControllerTest.php b/tests/functional/CapsuleControllerTest.php
index 804c5aef7c29292eba00e13b3b0a85841d298b90..5087c1d42362c3b383b3241d0b778d9f96b127c1 100644
--- a/tests/functional/CapsuleControllerTest.php
+++ b/tests/functional/CapsuleControllerTest.php
@@ -4,6 +4,7 @@ namespace App\Tests\functional;
 
 use App\Entity\Capsule;
 use App\Entity\User;
+use App\Tests\TestFileHelper;
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 use Symfony\Component\Filesystem\Filesystem;
 
@@ -16,14 +17,7 @@ class CapsuleControllerTest extends WebTestCase
 
     protected function setUp(): void
     {
-        $fileSystem = new Filesystem();
-        if (!$fileSystem->exists(self::TEST_DIR_PATH)) {
-            $fileSystem->mkdir(self::TEST_DIR_PATH, 0644);
-        }
-        $this->assertTrue(
-            $fileSystem->exists(self::TEST_DIR_PATH),
-            'The directory \'' . self::TEST_DIR_PATH . '\' should exists'
-        );
+        TestFileHelper::createLegacyDirectoryIfNecessary($this);
         chdir(self::TEST_DIR_PATH);
 
         self::ensureKernelShutdown();
diff --git a/tests/functional/ProjectControllerTest.php b/tests/functional/ProjectControllerTest.php
index e7daa45ee31158d60a0a7215946fcffb144c0db9..0eaf29baa71afb07680c8126c88072861ac18a83 100644
--- a/tests/functional/ProjectControllerTest.php
+++ b/tests/functional/ProjectControllerTest.php
@@ -4,6 +4,7 @@ namespace App\Tests\functional;
 
 use App\Entity\Capsule;
 use App\Entity\User;
+use App\Tests\TestFileHelper;
 use Doctrine\Persistence\ObjectManager;
 use Symfony\Bundle\FrameworkBundle\KernelBrowser;
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -21,14 +22,7 @@ class ProjectControllerTest extends WebTestCase
 
     protected function setUp(): void
     {
-        $fileSystem = new Filesystem();
-        if (!$fileSystem->exists(self::TEST_DIR_PATH)) {
-            $fileSystem->mkdir(self::TEST_DIR_PATH, 0644);
-        }
-        $this->assertTrue(
-            $fileSystem->exists(self::TEST_DIR_PATH),
-            'The directory \'' . self::TEST_DIR_PATH . '\' should exists'
-        );
+        TestFileHelper::createLegacyDirectoryIfNecessary($this);
         chdir(self::TEST_DIR_PATH);
 
         self::ensureKernelShutdown();