]> BookStack Code Mirror - system-cli/commitdiff
Fixed cwd warning during tests
authorDan Brown <redacted>
Thu, 7 Nov 2024 16:20:10 +0000 (16:20 +0000)
committerDan Brown <redacted>
Thu, 7 Nov 2024 16:20:10 +0000 (16:20 +0000)
A warning was shown due to the cwd being changed into a location which
was then later deleted. This resets the cwd before running the deletion.

tests/Commands/RestoreCommandTest.php
tests/TestCase.php

index 204bdd8653776dbf2ac2436dab2b2d1d6fe013bb..868b9aefd826ce6350f2a3acb314117e9339967a 100644 (file)
@@ -162,6 +162,7 @@ class RestoreCommandTest extends TestCase
         $this->assertStringEqualsFile('/var/www/bookstack-symlink-restore/storage/uploads/test.txt', 'hello-storage-uploads');
         $this->assertStringEqualsFile('/var/www/bookstack-symlink-restore/themes/test.txt', 'hello-themes');
 
+        $this->resetCurrentDirectory();
         exec('rm -rf /var/www/bookstack-symlink-restore');
         exec('rm -rf /symlinks');
     }
index 5683e46f28ae9f04d6ab27acd6f1051eaed81155..65db06fd12a6e92fb9568d94535466adf6ede7e9 100644 (file)
@@ -7,6 +7,14 @@ use Symfony\Component\Console\Tester\CommandTester;
 
 class TestCase extends \PHPUnit\Framework\TestCase
 {
+    /**
+     * Reset the current working directory to the application directory.
+     */
+    protected function resetCurrentDirectory(): void
+    {
+        chdir(dirname(__DIR__));
+    }
+
     protected function getTestDataDirectory(): string
     {
         return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test-data';