diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index 38e610c3b5..abb6073769 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -639,4 +639,11 @@ public function testGetDefaultDriveInstance() {
     $this->assertEquals([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]], $this->minkDefaultDriverArgs);
   }
 
+  /**
+   * Ensures we can't access modules we shouldn't be able to.
+   */
+  public function testProfileModules() {
+    drupal_get_filename('module', 'demo_umami_content');
+  }
+
 }
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index 2ba85e92e1..f654a94ff7 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -306,4 +306,11 @@ protected function tearDown() {
     }
   }
 
+  /**
+   * Ensures we can't access modules we shouldn't be able to.
+   */
+  public function testProfileModules() {
+    drupal_get_filename('module', 'drupal_system_listing_compatible_test');
+  }
+
 }
