diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index 38e610c3b5..2e8562b3f1 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -639,4 +639,13 @@ 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 after install.
+   */
+  public function testProfileModules() {
+    $this->setExpectedException(\InvalidArgumentException::class, 'The module demo_umami_content does not exist.');
+    $this->assertFileExists('core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml');
+    \Drupal::service('extension.list.module')->getPathname('demo_umami_content');
+  }
+
 }
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index 2ba85e92e1..55ca1b8596 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -306,4 +306,15 @@ protected function tearDown() {
     }
   }
 
+  /**
+   * Ensures KernelTestBase tests can access module's in profiles.
+   */
+  public function testProfileModules() {
+    $this->assertFileExists('core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml');
+    $this->assertSame(
+      'core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml',
+      \Drupal::service('extension.list.module')->getPathname('demo_umami_content')
+    );
+  }
+
 }
