You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: helpers.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2478,6 +2478,53 @@ protected $middleware = [
2478
2478
];
2479
2479
```
2480
2480
2481
+
<aname="disabling-defer-in-tests"></a>
2482
+
#### Disabling Deferred Functions in Tests
2483
+
2484
+
When writing tests, it may be useful to disable deferred functions. You may call `withoutDefer` in your test to instruct Laravel to invoke all deferred functions immediately:
2485
+
2486
+
```php tab=Pest
2487
+
test('without defer', function () {
2488
+
$this->withoutDefer();
2489
+
2490
+
// ...
2491
+
});
2492
+
```
2493
+
2494
+
```php tab=PHPUnit
2495
+
use Tests\TestCase;
2496
+
2497
+
class ExampleTest extends TestCase
2498
+
{
2499
+
public function test_without_defer(): void
2500
+
{
2501
+
$this->withoutDefer();
2502
+
2503
+
// ...
2504
+
}
2505
+
}
2506
+
```
2507
+
2508
+
If you would like to disable deferred functions for all tests within a test case, you may call the `withoutDefer` method from the `setUp` method on your base `TestCase` class:
2509
+
2510
+
```php
2511
+
<?php
2512
+
2513
+
namespace Tests;
2514
+
2515
+
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
2516
+
2517
+
abstract class TestCase extends BaseTestCase
2518
+
{
2519
+
protected function setUp(): void// [tl! add:start]
0 commit comments