summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/ProtoPayloadWorkflow.php
blob: 7adbed1ef4f41d133537a24a73c008c1c6c0010b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

namespace Temporal\Tests\Workflow;

use Temporal\Activity\ActivityOptions;
use Temporal\Api\Common\V1\WorkflowExecution;
use Temporal\Tests\Activity\SimpleActivity;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;

#[Workflow\WorkflowInterface]
class ProtoPayloadWorkflow
{
    #[WorkflowMethod(name: 'ProtoPayloadWorkflow')]
    public function handler(): iterable
    {
        $simple = Workflow::newActivityStub(
            SimpleActivity::class,
            ActivityOptions::new()->withStartToCloseTimeout(5)
        );

        $e = new WorkflowExecution();
        $e->setWorkflowId('workflow id');
        $e->setRunId('run id');

        /** @var WorkflowExecution $e2 */
        $e2 = yield $simple->updateRunID($e);
        assert($e2->getWorkflowId() === $e->getWorkflowId());
        assert($e2->getRunId() === 'updated');

        return $e2;
    }
}