-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enum as a input for workflow * Skip test for lower PHP version * Supress enum warning Co-authored-by: Sergey Zhuk <[email protected]>
- Loading branch information
1 parent
f10d8d5
commit 6e1067e
Showing
6 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Workflow; | ||
|
||
use Temporal\Workflow\WorkflowMethod; | ||
use Temporal\Workflow; | ||
use Temporal\Tests\Activity\SimpleActivity; | ||
use Temporal\Activity\ActivityOptions; | ||
use Temporal\Common\RetryOptions; | ||
use Temporal\Tests\Unit\DTO\Enum\ScalarEnum; | ||
|
||
#[Workflow\WorkflowInterface] | ||
class ScalarEnumWorkflow | ||
{ | ||
#[WorkflowMethod(name: 'ScalarEnumWorkflow')] | ||
public function handler(ScalarEnum $enum): iterable | ||
{ | ||
$simple = Workflow::newActivityStub( | ||
SimpleActivity::class, | ||
ActivityOptions::new() | ||
->withStartToCloseTimeout(5) | ||
->withRetryOptions( | ||
RetryOptions::new()->withMaximumAttempts(2) | ||
) | ||
); | ||
|
||
return yield $simple->scalarEnum($enum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Workflow; | ||
|
||
use Temporal\Workflow\WorkflowMethod; | ||
use Temporal\Workflow; | ||
use Temporal\Tests\Activity\SimpleActivity; | ||
use Temporal\Activity\ActivityOptions; | ||
use Temporal\Common\RetryOptions; | ||
use Temporal\Tests\Unit\DTO\Enum\SimpleEnum; | ||
|
||
#[Workflow\WorkflowInterface] | ||
class SimpleEnumWorkflow | ||
{ | ||
#[WorkflowMethod(name: 'SimpleEnumWorkflow')] | ||
public function handler(SimpleEnum $enum): iterable | ||
{ | ||
$simple = Workflow::newActivityStub( | ||
SimpleActivity::class, | ||
ActivityOptions::new() | ||
->withStartToCloseTimeout(5) | ||
->withRetryOptions( | ||
RetryOptions::new()->withMaximumAttempts(2) | ||
) | ||
); | ||
|
||
return yield $simple->simpleEnum($enum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Functional\Client; | ||
|
||
use Temporal\Tests\Workflow\SimpleEnumWorkflow; | ||
use Temporal\Tests\Unit\DTO\Enum\SimpleEnum; | ||
use Temporal\Tests\Workflow\ScalarEnumWorkflow; | ||
use Temporal\Tests\Unit\DTO\Enum\ScalarEnum; | ||
|
||
/** | ||
* @group client | ||
* @group functional | ||
*/ | ||
class EnumTestCase extends ClientTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (PHP_VERSION_ID < 80104) { | ||
$this->markTestSkipped(); | ||
} | ||
} | ||
|
||
public function testSimpleEnum(): void | ||
{ | ||
$client = $this->createClient(); | ||
$workflow = $client->newWorkflowStub(SimpleEnumWorkflow::class); | ||
|
||
$result = $client->start($workflow, SimpleEnum::TEST); | ||
|
||
$this->assertSame(SimpleEnum::TEST, $result->getResult(SimpleEnum::class)); | ||
} | ||
|
||
public function testScalarEnum(): void | ||
{ | ||
$client = $this->createClient(); | ||
$workflow = $client->newWorkflowStub(ScalarEnumWorkflow::class); | ||
|
||
$result = $client->start($workflow, ScalarEnum::TESTED_ENUM); | ||
|
||
$this->assertSame(ScalarEnum::TESTED_ENUM, $result->getResult(ScalarEnum::class)); | ||
} | ||
} |