Skip to content

Commit

Permalink
Add simple initMethod test
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jan 20, 2025
1 parent d9fec58 commit 70d1244
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/Acceptance/Extra/Workflow/InitMethodTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace Temporal\Tests\Acceptance\Extra\Workflow\InitMethod;

use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\Test;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Tests\Acceptance\App\Attribute\Stub;
use Temporal\Tests\Acceptance\App\TestCase;
use Temporal\Workflow;
use Temporal\Workflow\InitMethod;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;

#[CoversFunction('Temporal\Internal\Workflow\Process\Process::logRunningHandlers')]
class InitMethodTest extends TestCase
{
#[Test]
public function updateHandlersWithOneCall(
#[Stub(
type: 'Extra_Workflow_InitMethod',
args: [new Input('John Doe', 30)],
)] WorkflowStubInterface $stub,
): void {
$this->assertTrue($stub->getResult(timeout: 5));
}
}

#[WorkflowInterface]
class TestWorkflow
{
private array $initInput;

#[InitMethod]
public function __construct(Input $input) {
$this->initInput = \func_get_args();
}

#[WorkflowMethod(name: "Extra_Workflow_InitMethod")]
public function handle(Input $input)
{
return $this->initInput === \func_get_args();
}
}

class Input
{
public function __construct(
public string $name,
public int $age,
) {}
}

0 comments on commit 70d1244

Please sign in to comment.