Skip to content

Commit

Permalink
fix: update custom presets to reflect correct syntax and description
Browse files Browse the repository at this point in the history
  • Loading branch information
CamKem committed Sep 30, 2024
1 parent 49e4008 commit 35dbfa0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions arch-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,26 +672,35 @@ You may find all the expectations included in the `relaxed` preset below in our
<a name="preset-custom"></a>
### `custom`

Typically you don't need to use the `custom` preset, as you can use the `arch()` method to write your granular expectations. However, if you want to create your own preset, you can use the `custom` preset.
Typically, you don't need to create a `custom` preset, as you can use the `arch()` method to write your granular expectations. However, if you want to create your own preset, you can use the `custom` method to define the preset.

This may be useful if you have a set of expectations that you use frequently across multiple projects, or if you are plugin author and want to provide a set of expectations for your users.
This may be useful if you have a set of expectations that you use frequently across multiple projects, or if you are a plugin author and want to provide a set of expectations for your users.
```php
pest()->preset('ddd', function () {
pest()->presets()->custom('ddd', function () {
return [
expect('Infrastructure')->toOnlyBeUsedIn('Application'),
expect('Domain')->toOnlyBeUsedIn('Application'),
];
});
```

With the `preset` method, you may have access to the application PSR-4 namespaces on the first argument of your closure's callback.
Within the `custom` method, you may have access to the application PSR-4 namespaces on the first argument of your closure's callback.

```php
pest()->preset('silex', function (array $userNamespaces) {
dump($userNamespaces); // ['App\\']
pest()->presets()->custom('silex', function (array $userNamespaces) {
var_dump($userNamespaces); // array(1) { [0]=> string(3) "App" }
return [
expect($userNamespaces)->toBeArray(),
];
});
```

You can then use the `custom` preset by chaining the `preset()` method with the name of the custom preset.

```php
arch()->preset()->silex();
```

<a name="modifiers"></a>
## Modifiers

Expand Down

0 comments on commit 35dbfa0

Please sign in to comment.