Skip to content

Commit 0498164

Browse files
committed
fix: use method from metadata for live component test helper
1 parent 1a4bdc0 commit 0498164

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/LiveComponent/src/Test/TestLiveComponent.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,25 @@ public function __construct(
5151
$this->metadataFactory->getMetadata($mounted->getName())
5252
);
5353

54-
$this->client->request('GET', $this->router->generate(
55-
$this->metadata->get('route'),
56-
[
57-
'_live_component' => $this->metadata->getName(),
58-
'props' => json_encode($props->getProps(), flags: \JSON_THROW_ON_ERROR),
59-
]
60-
));
54+
if ('POST' === $method = strtoupper($this->metadata->get('method'))) {
55+
$this->client->request(
56+
$method,
57+
$this->router->generate($this->metadata->get('route'), [
58+
'_live_component' => $this->metadata->getName(),
59+
]),
60+
[
61+
'data' => json_encode(['props' => $props->getProps()]),
62+
],
63+
);
64+
} else {
65+
$this->client->request($method, $this->router->generate(
66+
$this->metadata->get('route'),
67+
[
68+
'_live_component' => $this->metadata->getName(),
69+
'props' => json_encode($props->getProps(), flags: \JSON_THROW_ON_ERROR),
70+
]
71+
));
72+
}
6173
}
6274

6375
public function render(): RenderedComponent

0 commit comments

Comments
 (0)