Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jul 27, 2023
1 parent 83fea2b commit 23c5549
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Fixtures/src/Workflow/Case335Workflow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* This file is part of Temporal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Temporal\Tests\Workflow;

use Temporal\Workflow;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowMethod;

#[Workflow\WorkflowInterface]
class Case335Workflow
{
private bool $exit = false;
private bool $timerRun = false;

#[SignalMethod('signal')]
public function signal()
{
$this->exit = true;

yield Workflow::timer(1);

$this->timerRun = true;
}

#[WorkflowMethod('case335_workflow')]
public function run()
{
yield Workflow::await(fn() => $this->exit);
return $this->timerRun;
}
}
12 changes: 12 additions & 0 deletions tests/Functional/Client/TypedStubTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Temporal\Tests\DTO\User;
use Temporal\Tests\Unit\Declaration\Fixture\WorkflowWithoutHandler;
use Temporal\Tests\Workflow\ActivityReturnTypeWorkflow;
use Temporal\Tests\Workflow\Case335Workflow;
use Temporal\Tests\Workflow\GeneratorWorkflow;
use Temporal\Tests\Workflow\QueryWorkflow;
use Temporal\Tests\Workflow\SignalledWorkflowReusable;
Expand Down Expand Up @@ -159,4 +160,15 @@ public function testSignalRunningWorkflowWithInheritedSignalViaParentInterface()
$result = $workflowRun->getResult();
$this->assertEquals(['test1'], $result);
}

public function testSignalResolvesCondidtionsBeforePromiseRun()
{
$client = $this->createClient();

$workflow = $client->newWorkflowStub(Case335Workflow::class);
$workflowRun = $client->startWithSignal($workflow, 'signal');

$result = $workflowRun->getResult('bool', 5);
$this->assertFalse($result);
}
}

0 comments on commit 23c5549

Please sign in to comment.