Skip to content

Commit 4f3ac83

Browse files
Add doc for wizard commands in testing
1 parent d87c014 commit 4f3ac83

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/guide/testing-with-sharp.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,39 @@ Call the Sharp API to delete an `$entityKey` instance on the Show Page.
5959

6060
Call the `$commandKeyOrClassName` Entity Command with the optional `$data`.
6161

62+
For a wizard command, you can call each step like this:
63+
```php
64+
$step = $this->callSharpEntityCommandFromList(
65+
'websiteDeploymentTargets',
66+
MyWizardEntityCommand::class,
67+
[
68+
'name' => 'Value 1',
69+
'other_key' => 2,
70+
]) // we are not defining the step here because it's the first step
71+
->assertOk()
72+
->json('step'); //get back the step key from the response
73+
74+
// call next step
75+
$this->callSharpEntityCommandFromList(
76+
'websiteDeploymentTargets',
77+
MyWizardEntityCommand::class,
78+
['another_key' => "Value 2"],
79+
commandStep: $step
80+
)->assertOk();
81+
```
82+
6283
#### `callSharpInstanceCommandFromList(string $entityKey, $instanceId, string $commandKeyOrClassName, array $data, ?string $commandStep = null)`
6384

6485
Call the `$commandKeyOrClassName` Instance Command with the optional `$data`.
6586

87+
For a wizard command, you can refer to the [previous example](#callsharpentitycommandfromlist-string-entitykey-string-commandkeyorclassname-array-data-string-commandstep-null).
88+
6689
#### `callSharpInstanceCommandFromShow(string $entityKey, $instanceId, string $commandKeyOrClassName, array $data, ?string $commandStep = null)`
6790

6891
Call the `$commandKeyOrClassName` Instance Command with the optional `$data`.
6992

93+
For a wizard command, you can refer to the [previous example](#callsharpentitycommandfromlist-string-entitykey-string-commandkeyorclassname-array-data-string-commandstep-null).
94+
7095
#### `withSharpBreadcrumb(Closure $callback): self`
7196

7297
Most of the time, the breadcrumb automatically set by Sharp is enough. But sometimes it can be useful to define a whole Sharp context before calling an endpoint, and that's the purpose of this method. The `$callback` contains a built instance of Code16\Sharp\Utils\Links\BreadcrumbBuilder, which can be used like this:

0 commit comments

Comments
 (0)