diff --git a/tests/src/Functional/FillPdfSettingsFormTest.php b/tests/src/Functional/FillPdfSettingsFormTest.php
index 8391ba0bdeeba36e7407d3a0738bc4d71c612aac..f377d58f3c38c61d7ea9bd3033a85e8a5b4f5a6b 100644
--- a/tests/src/Functional/FillPdfSettingsFormTest.php
+++ b/tests/src/Functional/FillPdfSettingsFormTest.php
@@ -149,7 +149,9 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
     // Now delete the directory and replace it with a file with the same name,
     // so the directory can't be recreated. Try saving again and verify an error
     // is set.
-    drupal_rmdir($directory);
+    /** @var \Drupal\Core\File\FileSystemInterface $file_system */
+    $file_system = $this->container->get('file_system');
+    $file_system->rmdir($directory);
     file_unmanaged_copy('public://.htaccess', $directory);
     $this->drupalPostForm(NULL, [], 'Save configuration');
     $this->assertSession()->pageTextNotContains('The configuration options have been saved.');