Skip to content

Commit 3e1ce5b

Browse files
WithCachedConfig docs (#10909)
* Update testing.md * Update testing.md * Update testing.md * Update testing.md * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 80c78bd commit 3e1ce5b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

testing.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Running Tests in Parallel](#running-tests-in-parallel)
88
- [Reporting Test Coverage](#reporting-test-coverage)
99
- [Profiling Tests](#profiling-tests)
10+
- [Caching Configuration](#caching-configuration)
1011

1112
<a name="introduction"></a>
1213
## Introduction
@@ -221,3 +222,34 @@ The Artisan test runner also includes a convenient mechanism for listing your ap
221222
```shell
222223
php artisan test --profile
223224
```
225+
226+
<a name="configuration-caching"></a>
227+
## Configuration Caching
228+
229+
When running tests, Laravel boots the application for each individual test method. Without a cached configuration file, each configuration file in 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, you may use the `Illuminate\Foundation\Testing\WithCachedConfig` trait:
230+
231+
```php tab=Pest
232+
<?php
233+
234+
use Illuminate\Foundation\Testing\WithCachedConfig;
235+
236+
pest()->use(WithCachedConfig::class);
237+
238+
// ...
239+
```
240+
241+
```php tab=PHPUnit
242+
<?php
243+
244+
namespace Tests\Feature;
245+
246+
use Illuminate\Foundation\Testing\WithCachedConfig;
247+
use Tests\TestCase;
248+
249+
class ConfigTest extends TestCase
250+
{
251+
use WithCachedConfig;
252+
253+
// ...
254+
}
255+
```

0 commit comments

Comments
 (0)