Skip to content

Commit b495454

Browse files
Use helper-style primitives in v2 test fixtures
The v2 authoring API supports two equivalent styles: namespaced helpers (the primary API, `use function Workflow\V2\activity;`) and the static facade (`Workflow::activity()`). Issue #171 calls for the helper style to be the primary example throughout fixtures so that new authors reading the test suite see it as the default. Three fixtures used `Workflow::now()`, `Workflow::uuid4()`, `Workflow::uuid7()`, and `Workflow::awaitSignal()` calls mixed with helper-style activity/all calls. Switch those to the namespaced helpers `now()`, `uuid4()`, `uuid7()`, and `await('<signal>')` so every fixture in the V2 suite reads in one consistent style. The static facade delegates to the same helpers, so behavior is identical.
1 parent d4a95ab commit b495454

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

tests/Fixtures/V2/TestDeterministicTimeWorkflow.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
namespace Tests\Fixtures\V2;
66

77
use function Workflow\V2\activity;
8+
use function Workflow\V2\now;
9+
810
use Workflow\V2\Workflow;
911

1012
final class TestDeterministicTimeWorkflow extends Workflow
1113
{
1214
public function handle(string $name): array
1315
{
14-
$timeAtStart = Workflow::now();
16+
$timeAtStart = now();
1517
$greeting = activity(TestGreetingActivity::class, $name);
16-
$timeAfterActivity = Workflow::now();
18+
$timeAfterActivity = now();
1719

1820
return [
1921
'greeting' => $greeting,

tests/Fixtures/V2/TestParallelDeterministicTimeWorkflow.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66

77
use function Workflow\V2\activity;
88
use function Workflow\V2\all;
9+
use function Workflow\V2\now;
10+
911
use Workflow\V2\Workflow;
1012

1113
final class TestParallelDeterministicTimeWorkflow extends Workflow
1214
{
1315
public function handle(string $firstName, string $secondName): array
1416
{
15-
$timeAtStart = Workflow::now();
17+
$timeAtStart = now();
1618

1719
$results = all([
1820
static fn () => activity(TestGreetingActivity::class, $firstName),
1921
static fn () => activity(TestGreetingActivity::class, $secondName),
2022
]);
2123

22-
$timeAfterParallel = Workflow::now();
24+
$timeAfterParallel = now();
2325

2426
return [
2527
'results' => $results,

tests/Fixtures/V2/TestUuidWorkflow.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
use Workflow\QueryMethod;
88
use Workflow\V2\Attributes\Signal;
99
use Workflow\V2\Attributes\Type;
10+
11+
use function Workflow\V2\await;
12+
use function Workflow\V2\uuid4;
13+
use function Workflow\V2\uuid7;
1014
use Workflow\V2\Workflow;
1115

1216
#[Type('test-uuid-workflow')]
@@ -24,11 +28,11 @@ final class TestUuidWorkflow extends Workflow
2428
public function handle(): array
2529
{
2630
$this->ids = [
27-
'uuid4' => [Workflow::uuid4(), Workflow::uuid4()],
28-
'uuid7' => [Workflow::uuid7(), Workflow::uuid7()],
31+
'uuid4' => [uuid4(), uuid4()],
32+
'uuid7' => [uuid7(), uuid7()],
2933
];
3034

31-
Workflow::awaitSignal('finish');
35+
await('finish');
3236

3337
return $this->ids;
3438
}

0 commit comments

Comments
 (0)