Skip to content

Commit

Permalink
docs: ddWhen and ddUnless
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Aug 9, 2023
1 parent eebe658 commit aacb44b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion expectations.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ In addition to the individual expectations available in Pest, the expectation AP

- [`and()`](#expect-and)
- [`dd()`](#expect-dd)
- [`ddWhen()`](#expect-ddWhen)
- [`ddUnless()`](#expect-ddUnless)
- [`each()`](#expect-each)
- [`json()`](#expect-json)
- [`match()`](#match)
Expand Down Expand Up @@ -680,7 +682,7 @@ expect($id)->toBe(14)

The `dd()` modifier

Use the `dd()` modifier allows you to dump the current expectation $value and stop the code execution. This can be useful for debugging by allowing you to inspect the current state of the $value at a particular point in your test.
Use the `dd()` modifier allows you to dump the current expectation `$value` and stop the code execution. This can be useful for debugging by allowing you to inspect the current state of the $value at a particular point in your test.

```php
expect(14)->dd(); // 14
Expand All @@ -690,6 +692,28 @@ expect([1, 2])->sequence(
);
```

<a name="expect-ddWhen"></a>
### `ddWhen($condition)`

Use the `ddWhen()` modifier allows you to dump the current expectation `$value` and stop the code execution when the given `$condition` is truthy.

```php
expect([1, 2])->each(
fn ($number) => $number->ddWhen(fn (int $number) => $number === 2) // 2
);
```

<a name="expect-ddUnless"></a>
### `ddUnless($condition)`

Use the `ddUnless()` modifier allows you to dump the current expectation `$value` and stop the code execution when the given `$condition` is falsy.

```php
expect([1, 2])->each(
fn ($number) => $number->ddUnless(fn (int $number) => $number === 1) // 2
);
```

<a name="expect-each"></a>
### `each()`

Expand Down

0 comments on commit aacb44b

Please sign in to comment.