Skip to content

Commit fff698b

Browse files
committed
feat: support xdebug in tests
1 parent 696700b commit fff698b

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

tests/Acceptance/App/Input/Command.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
}

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/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Temporal\Tests\Acceptance\App\RuntimeBuilder;
2828
use Temporal\Tests\Acceptance\App\Support;
2929

30-
chdir(__DIR__ . '/../..');
30+
\chdir(__DIR__ . '/../..');
3131
require './vendor/autoload.php';
3232

3333
RuntimeBuilder::init();
@@ -91,8 +91,8 @@
9191
$container->bindSingleton(ScheduleClientInterface::class, $scheduleClient);
9292
$container->bindInjector(WorkflowStubInterface::class, WorkflowStubInjector::class);
9393
$container->bindSingleton(DataConverterInterface::class, $converter);
94-
$container->bind(RPCInterface::class, static fn() => RPC::create(getenv('RR_RPC_ADDRESS') ?: 'tcp://127.0.0.1:6001'));
94+
$container->bind(RPCInterface::class, static fn() => RPC::create(\getenv('RR_RPC_ADDRESS') ?: 'tcp://127.0.0.1:6001'));
9595
$container->bind(
9696
StorageInterface::class,
97-
fn(#[Proxy] ContainerInterface $c): StorageInterface => $c->get(Factory::class)->select('harness'),
97+
static fn(#[Proxy] ContainerInterface $c): StorageInterface => $c->get(Factory::class)->select('harness'),
9898
);

tests/Functional/.rr.silent.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ rpc:
55

66
server:
77
command: "php worker.php"
8-
env:
9-
XDEBUG_SESSION: 1
108

119
# Workflow and activity mesh service
1210
temporal:

0 commit comments

Comments
 (0)