Skip to content

Commit 23f6089

Browse files
committed
Better doc
1 parent ac7e1a6 commit 23f6089

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

docs/guide/testing-with-sharp.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,32 @@ 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:
62+
In case of a wizard command, here’s how you can specify the step in the `$commandStep` parameter:
63+
6364
```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
65+
it('allows the user to use the wizard', function () {
66+
// First step, no need to declare any previous step
67+
$step = $this
68+
->callSharpEntityCommandFromList(
69+
entityKey: 'myCommand',
70+
commandKeyOrClassName: MyWizardCommand::class,
71+
data: ['some_key' => 'some value'],
72+
)
7173
->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();
74+
->json('step'); // Get back the step key from the response
75+
76+
// Second step
77+
$this
78+
->callSharpEntityCommandFromList(
79+
entityKey: 'myCommand',
80+
commandKeyOrClassName: MyWizardCommand::class,
81+
data: ['another_key' => 'another value'],
82+
commandStep: $step // We must specify the step we got from the first call
83+
)
84+
->assertOk();
85+
86+
// ...
87+
});
8188
```
8289

8390
#### `callSharpInstanceCommandFromList(string $entityKey, $instanceId, string $commandKeyOrClassName, array $data, ?string $commandStep = null)`
@@ -97,7 +104,7 @@ For a wizard command, you can refer to the [previous example](#callsharpentityco
97104
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:
98105

99106
```php
100-
it('allow the user to display a leaf form', function () {
107+
it('allows the user to display a leaf form', function () {
101108
$this
102109
->loginAsSharpUser()
103110
->withSharpBreadcrumb(function (BreadcrumbBuilder $builder) {

0 commit comments

Comments
 (0)