Skip to content

Commit

Permalink
chore(PHP): add feature signal\signal_with_start
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jun 14, 2024
1 parent 3d4cd29 commit 9352318
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions features/signal/signal_with_start/feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Harness\Feature\Signal\SignalWithStart;

use Harness\Attribute\Check;
use Harness\Runtime\Feature;
use Temporal\Client\WorkflowClientInterface;
use Temporal\Client\WorkflowOptions;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Webmozart\Assert\Assert;

#[WorkflowInterface]
class FeatureWorkflow
{
private int $value = 0;

#[WorkflowMethod('Workflow')]
public function run(): int
{
return $this->value;
}

#[SignalMethod('add')]
public function add(int $arg): void
{
$this->value += $arg;
}
}

class FeatureChecker
{
#[Check]
public static function check(
WorkflowClientInterface $client,
Feature $feature,
): void {
$stub = $client->newWorkflowStub(
FeatureWorkflow::class,
WorkflowOptions::new()->withTaskQueue($feature->taskQueue),
);
$run = $client->startWithSignal($stub, 'add', [42]);
// See https://github.com/temporalio/sdk-php/issues/457
Assert::same($run->getResult(), 42, 'Signal must be executed before Workflow handler');
}
}

0 comments on commit 9352318

Please sign in to comment.