Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/Acceptance/Extra/Activity/ActivityInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityMethod;
use Temporal\Activity\ActivityOptions;

class ActivityInfoTest extends TestCase
{
Expand Down Expand Up @@ -51,7 +54,7 @@ private function getRetryOptions(): PromiseInterface
{
return Workflow::newActivityStub(
TestActivity::class,
Activity\ActivityOptions::new()
ActivityOptions::new()
->withRetryOptions(
RetryOptions::new()
->withMaximumAttempts(20)
Expand All @@ -65,10 +68,10 @@ private function getRetryOptions(): PromiseInterface
}
}

#[Activity\ActivityInterface(prefix: 'Extra_Activity_ActivityInfo.')]
#[ActivityInterface(prefix: 'Extra_Activity_ActivityInfo.')]
class TestActivity
{
#[Activity\ActivityMethod]
#[ActivityMethod]
public function retryOptions()
{
return Activity::getInfo()->retryOptions;
Expand Down
8 changes: 4 additions & 4 deletions tests/Acceptance/Extra/Activity/ActivityMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Temporal\Tests\Acceptance\Extra\Activity\ActivityMethod;

use Temporal\Activity;
use Temporal\Activity\ActivityMethod;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Exception\Client\WorkflowFailedException;
Expand All @@ -14,6 +13,8 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityOptions;

class ActivityMethodTest extends TestCase
{
Expand Down Expand Up @@ -52,7 +53,6 @@ public function testMagicMethodIsIgnored(
}
}


#[WorkflowInterface]
class TestWorkflow
{
Expand All @@ -61,7 +61,7 @@ public function handle(string $method)
{
$activityStub = Workflow::newActivityStub(
TestActivity::class,
Activity\ActivityOptions::new()->withScheduleToCloseTimeout(10),
ActivityOptions::new()->withScheduleToCloseTimeout(10),
);
$result = yield $activityStub->{$method}();

Expand All @@ -72,7 +72,7 @@ public function handle(string $method)
}
}

#[Activity\ActivityInterface(prefix: 'Extra_Activity_ActivityMethod.')]
#[ActivityInterface(prefix: 'Extra_Activity_ActivityMethod.')]
class TestActivity
{
#[ActivityMethod]
Expand Down
9 changes: 6 additions & 3 deletions tests/Acceptance/Extra/Activity/ActivityPausedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityMethod;
use Temporal\Activity\ActivityOptions;

class ActivityPausedTest extends TestCase
{
Expand Down Expand Up @@ -67,7 +70,7 @@ class TestWorkflow
public function handle()
{
$stub = Workflow::newUntypedActivityStub(
Activity\ActivityOptions::new()->withScheduleToCloseTimeout('101 seconds'),
ActivityOptions::new()->withScheduleToCloseTimeout('101 seconds'),
);

/** @see TestActivity::sleep() */
Expand All @@ -82,10 +85,10 @@ public function handle()
}
}

#[Activity\ActivityInterface(prefix: 'Extra_Activity_ActivityPaused.')]
#[ActivityInterface(prefix: 'Extra_Activity_ActivityPaused.')]
class TestActivity
{
#[Activity\ActivityMethod]
#[ActivityMethod]
public function sleep(int $seconds): string
{
$start = \microtime(true);
Expand Down
3 changes: 2 additions & 1 deletion tests/Acceptance/Extra/Client/WorkflowClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\WorkflowExecutionStatus;

class WorkflowClientTest extends TestCase
{
Expand Down Expand Up @@ -48,7 +49,7 @@ public function describeWorkflowExecution(

self::assertInstanceOf(\DateTimeInterface::class, $description->info->startTime);
self::assertNull($description->info->closeTime);
self::assertSame(Workflow\WorkflowExecutionStatus::Running, $description->info->status);
self::assertSame(WorkflowExecutionStatus::Running, $description->info->status);
self::assertGreaterThanOrEqual(2, $description->info->historyLength);
self::assertNull($description->info->parentExecution);
self::assertNotNull($description->info->executionTime);
Expand Down
17 changes: 11 additions & 6 deletions tests/Acceptance/Extra/Interceptors/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInit;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityMethod;
use Temporal\Activity\ActivityOptions;

#[Worker(pipelineProvider: [WorkerServices::class, 'interceptors'])]
class ContextTest extends TestCase
Expand Down Expand Up @@ -105,7 +110,7 @@ public function handle(string $class)
$activityClass = yield Workflow::executeActivity(
'Extra_Interceptors_Context.handler',
['foo'],
Activity\ActivityOptions::new()->withScheduleToCloseTimeout('10 seconds'),
ActivityOptions::new()->withScheduleToCloseTimeout('10 seconds'),
);
yield Workflow::await(fn() => $this->exit);
return [
Expand All @@ -115,7 +120,7 @@ public function handle(string $class)
];
}

#[Workflow\SignalMethod]
#[SignalMethod]
public function exit(): void
{
$this->exit = true;
Expand All @@ -125,7 +130,7 @@ public function exit(): void
#[WorkflowInterface]
class TestFailingWorkflow
{
#[Workflow\WorkflowInit]
#[WorkflowInit]
public function __construct(mixed ...$input)
{
if ($input === []) {
Expand All @@ -145,7 +150,7 @@ class TestReadonlyConstructorWorkflow
{
private ?PromiseInterface $uuid = null;

#[Workflow\WorkflowInit]
#[WorkflowInit]
public function __construct(mixed ...$input)
{
try {
Expand All @@ -162,10 +167,10 @@ public function handle()
}
}

#[Activity\ActivityInterface(prefix: 'Extra_Interceptors_Context.')]
#[ActivityInterface(prefix: 'Extra_Interceptors_Context.')]
class TestActivity
{
#[Activity\ActivityMethod]
#[ActivityMethod]
public function handler(string $result): string
{
return $result;
Expand Down
3 changes: 2 additions & 1 deletion tests/Acceptance/Extra/Stability/DestroyableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Temporal\Tests\Acceptance\App\TestCase;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\WorkflowInterface;

class DestroyableTest extends TestCase
{
Expand All @@ -30,7 +31,7 @@ public function destroyOnFinish(
}
}

#[Workflow\WorkflowInterface]
#[WorkflowInterface]
class TestWorkflow implements Destroyable
{
private LoggerInterface $logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Temporal\Tests\Acceptance\App\TestCase;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\WorkflowInterface;

class DynamicSignalWithPromisesTest extends TestCase
{
Expand All @@ -37,7 +38,7 @@ public function steps(
}
}

#[Workflow\WorkflowInterface]
#[WorkflowInterface]
class TestWorkflow
{
#[WorkflowMethod(name: 'Extra_Stability_DynamicSignalWithPromises')]
Expand Down
9 changes: 6 additions & 3 deletions tests/Acceptance/Extra/Stability/ResetWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Temporal\Workflow;
use Temporal\Workflow\ReturnType;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\QueryMethod;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInterface;

class ResetWorkerTest extends TestCase
{
Expand Down Expand Up @@ -111,7 +114,7 @@ public function resetWithSignal(
}
}

#[Workflow\WorkflowInterface]
#[WorkflowInterface]
class TestWorkflow
{
private bool $exit = false;
Expand All @@ -125,14 +128,14 @@ public function expire(int $seconds = 10): \Generator
return yield $isTimer ? 'Timer' : 'Signal';
}

#[Workflow\QueryMethod('die')]
#[QueryMethod('die')]
public function die(int $sleep = 2): void
{
\sleep($sleep);
exit(1);
}

#[Workflow\SignalMethod('exit')]
#[SignalMethod('exit')]
public function signal()
{
yield Workflow::uuid7();
Expand Down
3 changes: 2 additions & 1 deletion tests/Acceptance/Extra/Update/DynamicUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\SignalMethod;

class DynamicUpdateTest extends TestCase
{
Expand Down Expand Up @@ -88,7 +89,7 @@ public function handle()
return $this->result;
}

#[Workflow\SignalMethod]
#[SignalMethod]
public function exit(): void
{
$this->exit = true;
Expand Down
3 changes: 2 additions & 1 deletion tests/Acceptance/Extra/Update/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\UpdateMethod;

class TimeoutTest extends TestCase
{
Expand Down Expand Up @@ -67,7 +68,7 @@ public function handle()
yield Workflow::await(static fn() => false);
}

#[Workflow\UpdateMethod(name: 'sleep')]
#[UpdateMethod(name: 'sleep')]
public function sleep(string $sleep): mixed
{
yield Workflow::timer(\DateInterval::createFromDateString($sleep));
Expand Down
20 changes: 12 additions & 8 deletions tests/Acceptance/Extra/Update/UntypedStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
use Temporal\Workflow;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Workflow\QueryMethod;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\UpdateMethod;
use Temporal\Workflow\UpdateValidatorMethod;

class UntypedStubTest extends TestCase
{
Expand Down Expand Up @@ -271,15 +275,15 @@ public function handle()
* @param non-empty-string $name
* @return mixed
*/
#[Workflow\UpdateMethod(name: 'await')]
#[UpdateMethod(name: 'await')]
public function add(string $name): mixed
{
$this->awaits[$name] ??= null;
yield Workflow::await(fn() => $this->awaits[$name] !== null);
return $this->awaits[$name];
}

#[Workflow\UpdateValidatorMethod(forUpdate: 'await')]
#[UpdateValidatorMethod(forUpdate: 'await')]
public function validateAdd(string $name): void
{
empty($name) and throw new \InvalidArgumentException('Name must not be empty');
Expand All @@ -289,7 +293,7 @@ public function validateAdd(string $name): void
* @param non-empty-string $name
* @return PromiseInterface<bool>
*/
#[Workflow\UpdateMethod(name: 'awaitWithTimeout')]
#[UpdateMethod(name: 'awaitWithTimeout')]
public function addWithTimeout(string $name, string|int $timeout, mixed $value): mixed
{
$this->awaits[$name] ??= null;
Expand All @@ -309,7 +313,7 @@ public function addWithTimeout(string $name, string|int $timeout, mixed $value):
return $this->awaits[$name];
}

#[Workflow\UpdateValidatorMethod(forUpdate: 'awaitWithTimeout')]
#[UpdateValidatorMethod(forUpdate: 'awaitWithTimeout')]
public function validateAddWithTimeout(string $name, string|int $timeout, mixed $value): void
{
$value === null and throw new \InvalidArgumentException('Value must not be null');
Expand All @@ -323,13 +327,13 @@ public function validateAddWithTimeout(string $name, string|int $timeout, mixed
* @param non-empty-string $name
* @return mixed
*/
#[Workflow\UpdateMethod(name: 'resolveValue')]
#[UpdateMethod(name: 'resolveValue')]
public function resolve(string $name, mixed $value): mixed
{
return $this->awaits[$name] = $value;
}

#[Workflow\UpdateValidatorMethod(forUpdate: 'resolveValue')]
#[UpdateValidatorMethod(forUpdate: 'resolveValue')]
public function validateResolve(string $name, mixed $value): void
{
$value === null and throw new \InvalidArgumentException('Value must not be null');
Expand All @@ -341,13 +345,13 @@ public function validateResolve(string $name, mixed $value): void
* @param non-empty-string $name
* @return mixed
*/
#[Workflow\QueryMethod(name: 'getValue')]
#[QueryMethod(name: 'getValue')]
public function get(string $name): mixed
{
return $this->awaits[$name] ?? null;
}

#[Workflow\SignalMethod]
#[SignalMethod]
public function exit(): void
{
$this->exit = true;
Expand Down
Loading
Loading