Skip to content

Commit 1df82d6

Browse files
authored
Merge branch 'master' into symfony-8.0
2 parents de70bed + c8b5825 commit 1df82d6

File tree

14 files changed

+87
-26
lines changed

14 files changed

+87
-26
lines changed

.run/Acceptance.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Acceptance" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
3+
<TestRunner bootstrap_file="$PROJECT_DIR$/tests/bootstrap.php" configuration_file="$PROJECT_DIR$/phpunit.xml.dist" directory="$PROJECT_DIR$/tests/Acceptance" scope="XML" options="--testsuite=Acceptance" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

.run/Functional.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Functional" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
3+
<TestRunner bootstrap_file="$PROJECT_DIR$/tests/bootstrap.php" configuration_file="$PROJECT_DIR$/phpunit.xml.dist" directory="$PROJECT_DIR$/tests/Functional" scope="XML" options="--testsuite=Functional" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

.run/Unit.run.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Unit" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
3+
<TestRunner bootstrap_file="$PROJECT_DIR$/tests/bootstrap.php" configuration_file="$PROJECT_DIR$/phpunit.xml.dist" directory="$PROJECT_DIR$/tests/Functional" scope="XML" options="--testsuite=Unit" />
4+
<method v="2" />
5+
</configuration>
6+
</component>

resources/.phpstorm.meta.php/.phpstorm.meta.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@
6262
override(\Temporal\Client\WorkflowClient::newRunningWorkflowStub(), map([
6363
'' => type(0),
6464
]));
65+
66+
override(\Temporal\Client\WorkflowStubInterface::getResult(), map([
67+
'' => '@',
68+
]));
6569
}

resources/workflow.meta-storm.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,11 @@
7474
<collection name="temporal/sdk:activity-class" argument="0" />
7575
<stopCompletion />
7676
</classMethod>
77+
<classMethod
78+
class="\Temporal\Workflow\WorkflowRunInterface"
79+
method="getResult"
80+
argument="0">
81+
<languageInjection language="InjectablePHP" prefix="/** @var " suffix="$_ **/" />
82+
</classMethod>
7783
</definitions>
7884
</meta-storm>
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Temporal\Tests\Acceptance\App\Input;
5+
namespace Temporal\Testing;
66

77
final class Command
88
{
@@ -18,12 +18,19 @@ final class Command
1818
/** @var non-empty-string|null */
1919
public ?string $tlsCert = null;
2020

21+
private array $xdebug;
22+
2123
public static function fromEnv(): self
2224
{
2325
$self = new self();
2426

2527
$self->namespace = \getenv('TEMPORAL_NAMESPACE') ?: 'default';
2628
$self->address = \getenv('TEMPORAL_ADDRESS') ?: 'localhost:7233';
29+
$self->xdebug = [
30+
'xdebug.mode' => \ini_get('xdebug.mode'),
31+
'xdebug.start_with_request' => \ini_get('xdebug.start_with_request'),
32+
'xdebug.start_upon_error' => \ini_get('xdebug.start_upon_error'),
33+
];
2734
// $self->tlsCert =
2835
// $self->tlsKey =
2936

@@ -66,7 +73,7 @@ public static function fromCommandLine(array $argv): self
6673
/**
6774
* @return list<non-empty-string> CLI arguments that can be parsed by `fromCommandLine`
6875
*/
69-
public function toCommandLineArguments(): array
76+
public function getCommandLineArguments(): array
7077
{
7178
$result = [];
7279
$this->namespace === null or $result[] = "namespace=$this->namespace";
@@ -76,4 +83,13 @@ public function toCommandLineArguments(): array
7683

7784
return $result;
7885
}
86+
87+
public function getPhpBinaryArguments(): array
88+
{
89+
$result = [];
90+
foreach ($this->xdebug as $key => $value) {
91+
$result[] = "-d$key=$value";
92+
}
93+
return $result;
94+
}
7995
}

testing/src/Environment.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ public function startTemporalServer(
101101
);
102102
$this->temporalServerProcess->setTimeout($commandTimeout);
103103
$this->temporalServerProcess->start();
104-
$this->output->writeln('<info>done.</info>');
105-
\sleep(1);
104+
105+
$deadline = \microtime(true) + 1.2;
106+
while (!$this->temporalServerProcess->isRunning() && \microtime(true) < $deadline) {
107+
\usleep(10_000);
108+
}
106109

107110
if (!$this->temporalServerProcess->isRunning()) {
108111
$this->output->writeln('<error>error</error>');
109112
$this->output->writeln('Error starting Temporal server: ' . $this->temporalServerProcess->getErrorOutput());
110113
exit(1);
111114
}
115+
$this->output->writeln('<info>done.</info>');
112116
}
113117

114118
public function startTemporalTestServer(int $commandTimeout = 10): void
@@ -127,14 +131,15 @@ public function startTemporalTestServer(int $commandTimeout = 10): void
127131
);
128132
$this->temporalTestServerProcess->setTimeout($commandTimeout);
129133
$this->temporalTestServerProcess->start();
130-
$this->output->writeln('<info>done.</info>');
134+
131135
\sleep(1);
132136

133137
if (!$this->temporalTestServerProcess->isRunning()) {
134138
$this->output->writeln('<error>error</error>');
135139
$this->output->writeln('Error starting Temporal Test server: ' . $this->temporalTestServerProcess->getErrorOutput());
136140
exit(1);
137141
}
142+
$this->output->writeln('<info>done.</info>');
138143
}
139144

140145
/**

tests/Acceptance/App/Runtime/RRStarter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ public function start(): void
3939
"temporal.address={$this->runtime->address}",
4040
'-o',
4141
'server.command=' . \implode(',', [
42-
'php',
42+
PHP_BINARY,
43+
...$run->getPhpBinaryArguments(),
4344
$this->runtime->rrConfigDir . DIRECTORY_SEPARATOR . 'worker.php',
44-
...$run->toCommandLineArguments(),
45+
...$run->getCommandLineArguments(),
4546
]),
4647
];
4748
$run->tlsKey === null or $rrCommand = [...$rrCommand, '-o', "tls.key={$run->tlsKey}"];

tests/Acceptance/App/Runtime/State.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Temporal\Tests\Acceptance\App\Runtime;
66

7-
use Temporal\Tests\Acceptance\App\Input\Command;
87
use Temporal\DataConverter\PayloadConverterInterface;
8+
use Temporal\Testing\Command;
99

1010
final class State
1111
{

tests/Acceptance/App/RuntimeBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PHPUnit\Framework\Attributes\Test;
88
use Temporal\Activity\ActivityInterface;
99
use Temporal\DataConverter\PayloadConverterInterface;
10-
use Temporal\Tests\Acceptance\App\Input\Command;
10+
use Temporal\Testing\Command;
1111
use Temporal\Tests\Acceptance\App\Input\Feature;
1212
use Temporal\Tests\Acceptance\App\Runtime\State;
1313
use Temporal\Worker\FeatureFlags;

0 commit comments

Comments
 (0)