]> BookStack Code Mirror - bookstack/blobdiff - tests/Commands/CleanupImagesCommandTest.php
Cleanup Command: Allowed running non-interactively
[bookstack] / tests / Commands / CleanupImagesCommandTest.php
index a1a5ab98540e58cebc655f177e052021ef5b4f69..36fd51e968ea4d0e4a56c8c19ebeb1dc04b46aee 100644 (file)
@@ -14,7 +14,7 @@ class CleanupImagesCommandTest extends TestCase
 
         $this->artisan('bookstack:cleanup-images -v')
             ->expectsOutput('Dry run, no images have been deleted')
-            ->expectsOutput('1 images found that would have been deleted')
+            ->expectsOutput('1 image(s) found that would have been deleted')
             ->expectsOutputToContain($image->path)
             ->assertExitCode(0);
 
@@ -29,7 +29,7 @@ class CleanupImagesCommandTest extends TestCase
         $this->artisan('bookstack:cleanup-images --force')
             ->expectsOutputToContain('This operation is destructive and is not guaranteed to be fully accurate')
             ->expectsConfirmation('Are you sure you want to proceed?', 'yes')
-            ->expectsOutput('1 images deleted')
+            ->expectsOutput('1 image(s) deleted')
             ->assertExitCode(0);
 
         $this->assertDatabaseMissing('images', ['id' => $image->id]);
@@ -46,4 +46,17 @@ class CleanupImagesCommandTest extends TestCase
 
         $this->assertDatabaseHas('images', ['id' => $image->id]);
     }
+
+    public function test_command_force_no_interaction_run()
+    {
+        $page = $this->entities->page();
+        $image = Image::factory()->create(['uploaded_to' => $page->id]);
+
+        $this->artisan('bookstack:cleanup-images --force --no-interaction')
+            ->expectsOutputToContain('This operation is destructive and is not guaranteed to be fully accurate')
+            ->expectsOutput('1 image(s) deleted')
+            ->assertExitCode(0);
+
+        $this->assertDatabaseMissing('images', ['id' => $image->id]);
+    }
 }