summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/SimpleDTOWorkflow.php
blob: bd39a0a02dc7bb2cfd00d8ea0d0b9dd020f3cf6d (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
34
35
<?php

declare(strict_types=1);

namespace Temporal\Tests\Workflow;

use Temporal\Activity\ActivityOptions;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Tests\Activity\SimpleActivity;
use Temporal\Tests\DTO\Message;
use Temporal\Tests\DTO\User;

#[Workflow\WorkflowInterface]
class SimpleDTOWorkflow
{
    #[WorkflowMethod(name: 'SimpleDTOWorkflow')]//, returnType: Message::class)]
    public function handler(
        User $user
    ) {
        $simple = Workflow::newActivityStub(
            SimpleActivity::class,
            ActivityOptions::new()
                ->withStartToCloseTimeout(5)
        );

        $value = yield $simple->greet($user);

        if (!$value instanceof Message) {
            return "FAIL";
        }

        return $value;
    }
}