Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Jan 24, 2025
1 parent c2fe995 commit 2220f98
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,31 +450,30 @@ try {

## WorkflowTrait

The `WorkflowTrait` provides methods `execute()` and `run()` methods for easing handling a Workflow.
The `WorkflowTrait` provides methods `execute` and `run` for easing handling a Workflow within a class.

```php
use Chevere\Workflow\WorkflowTrait;

class MyAction
class Something
{
use WorkflowTrait;

public function main(): void
public function __construct()
{
$workflow = workflow(
job1: sync(
new MyAction(),
foo: variable('bar')
)
);
$this->execute($workflow, foo: $bar);
// Use execute to run the Workflow
$this->execute($workflow, bar: 'baz');
}
}

$action = new MyAction();
$action->main();
// Once executed you can get the response
$bar = $action->run()->response('job1')->string();
$some = new Something();
$bar = $some->run()->response('job1')->string();
```

## Demo
Expand Down Expand Up @@ -547,9 +546,11 @@ assertSame(
);
```

### PHPUnit test Workflow
### Testing with PHPUnit

Use `ExpectWorkflowExceptionTrait` for testing Workflow definitions using PHPUnit.

Use `ExpectWorkflowExceptionTrait` for testing Workflow definitions using PHPUnit. Wrap the logic that runs the Workflow in a closure and use `expectWorkflowException` method to assert the expected exception.
Wrap the logic that runs the Workflow in a closure and use `expectWorkflowException` method to assert the expected exception.

```php
use Chevere\Workflow\Traits\ExpectWorkflowExceptionTrait;
Expand Down

0 comments on commit 2220f98

Please sign in to comment.