77use PHPUnit \Framework \Attributes \Test ;
88use Temporal \Activity ;
99use Temporal \Api \Common \V1 \WorkflowExecution ;
10- use Temporal \Api \Workflowservice \V1 \DescribeWorkflowExecutionRequest ;
1110use Temporal \Api \Workflowservice \V1 \PauseActivityRequest ;
1211use Temporal \Client \GRPC \ServiceClientInterface ;
1312use Temporal \Client \WorkflowClientInterface ;
@@ -28,27 +27,20 @@ public function simplePause(
2827 WorkflowClientInterface $ workflowClient ,
2928 ): void {
3029 $ deadline = \microtime (true ) + 10 ;
31- $ started = false ;
32- while (\microtime (true ) < $ deadline ) {
33- $ response = $ serviceClient ->DescribeWorkflowExecution (
34- (new DescribeWorkflowExecutionRequest ())
35- ->setNamespace ('default ' )
36- ->setExecution (
37- (new WorkflowExecution ())
38- ->setWorkflowId ($ stub ->getExecution ()->getID ())
39- ->setRunId ($ stub ->getExecution ()->getRunID ()),
40- ),
41- );
42- foreach ($ response ->getPendingActivities () as $ pending ) {
43- if ($ pending ->hasLastStartedTime ()) {
44- $ started = true ;
45- break 2 ;
46- }
30+ find:
31+ $ found = false ;
32+ foreach ($ workflowClient ->getWorkflowHistory ($ stub ->getExecution ()) as $ event ) {
33+ if ($ event ->hasActivityTaskScheduledEventAttributes ()) {
34+ $ found = true ;
35+ break ;
4736 }
48- \usleep (50_000 );
4937 }
5038
51- self ::assertTrue ($ started , 'Activity did not reach STARTED state in pending_activities ' );
39+ if (!$ found && \microtime (true ) < $ deadline ) {
40+ goto find;
41+ }
42+
43+ self ::assertTrue ($ found , '`Activity task started` event not found in workflow history ' );
5244
5345 $ serviceClient ->PauseActivity (
5446 (new PauseActivityRequest ())
0 commit comments