From b00561afdae9dbfd42009e1e2199620471a5600f Mon Sep 17 00:00:00 2001
From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com>
Date: Wed, 12 Nov 2025 12:32:23 -0500
Subject: [PATCH 1/4] Update testing.md
---
testing.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/testing.md b/testing.md
index 8532d5235ba..e064692e790 100644
--- a/testing.md
+++ b/testing.md
@@ -2,6 +2,7 @@
- [Introduction](#introduction)
- [Environment](#environment)
+- [Caching Configuration](#caching-config)
- [Creating Tests](#creating-tests)
- [Running Tests](#running-tests)
- [Running Tests in Parallel](#running-tests-in-parallel)
@@ -31,6 +32,61 @@ You are free to define other testing environment configuration values as necessa
In addition, you may create a `.env.testing` file in the root of your project. This file will be used instead of the `.env` file when running Pest and PHPUnit tests or executing Artisan commands with the `--env=testing` option.
+
+## Caching Config
+
+When running tests, Laravel boots the application for each individual test method. Without a cached configuration file, each config file must be loaded and parsed. To build the configuration once and re-use it for all tests in a single run, Laravel offers the `Illuminate\Foundation\Testing\WithCachedConfig` trait.
+
+``php tab=Pest
+use(WithCachedConfig::class);
+
+test('modifies config', function () {
+ config(['services.postmark.key' => 'xyz']);
+ expect(config('services.postmark.key'))->toBe('xyz');
+});
+
+test('uses default config', function () {
+ expect(config('services.postmark.key'))->not->toBe('xyz');
+});
+```
+
+```php tab=PHPUnit
+assertEquals('xyz', config('services.postmark.key'));
+ }
+
+ /**
+ * A test that makes no modification to the config.
+ */
+ public function test_uses_default_config(): void
+ {
+ $this->assertNotEquals('xyz', config('services.postmark.key'));
+ }
+}
+```
+
+> [!NOTE]
+> Changes to the cache in one test case should not affect the configuration that is loaded in subsequent tests.
+
## Creating Tests
From a0a5f78287c1ef9a250508e114ec2db56cd88e21 Mon Sep 17 00:00:00 2001
From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com>
Date: Wed, 12 Nov 2025 12:33:18 -0500
Subject: [PATCH 2/4] Update testing.md
---
testing.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testing.md b/testing.md
index e064692e790..f6514fb7b31 100644
--- a/testing.md
+++ b/testing.md
@@ -37,7 +37,7 @@ In addition, you may create a `.env.testing` file in the root of your project. T
When running tests, Laravel boots the application for each individual test method. Without a cached configuration file, each config file must be loaded and parsed. To build the configuration once and re-use it for all tests in a single run, Laravel offers the `Illuminate\Foundation\Testing\WithCachedConfig` trait.
-``php tab=Pest
+```php tab=Pest
Date: Wed, 12 Nov 2025 12:34:25 -0500
Subject: [PATCH 3/4] Update testing.md
---
testing.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testing.md b/testing.md
index f6514fb7b31..368bb247a19 100644
--- a/testing.md
+++ b/testing.md
@@ -35,7 +35,7 @@ In addition, you may create a `.env.testing` file in the root of your project. T
## Caching Config
-When running tests, Laravel boots the application for each individual test method. Without a cached configuration file, each config file must be loaded and parsed. To build the configuration once and re-use it for all tests in a single run, Laravel offers the `Illuminate\Foundation\Testing\WithCachedConfig` trait.
+When running tests, Laravel boots the application for each individual test method. Without a cached configuration file, each config file for your application must be loaded at the start of a test. To build the configuration once and re-use it for all tests in a single run, Laravel offers the `Illuminate\Foundation\Testing\WithCachedConfig` trait.
```php tab=Pest
Date: Thu, 13 Nov 2025 05:58:20 -0500
Subject: [PATCH 4/4] Update testing.md
---
testing.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/testing.md b/testing.md
index 368bb247a19..e67e402ec72 100644
--- a/testing.md
+++ b/testing.md
@@ -71,6 +71,7 @@ class ConfigTest extends TestCase
*/
public function test_modifies_config(): void
{
+ config(['services.postmark.key' => 'xyz']);
$this->assertEquals('xyz', config('services.postmark.key'));
}