Skip to content

Commit 13b16bd

Browse files
committed
Fix functional tests
1 parent 3cfdaf9 commit 13b16bd

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public function testCanRenderComponentAsHtmlOrJson(): void
5555

5656
$this->browser()
5757
->throwExceptions()
58-
->get('/_components/component1?'.http_build_query($dehydrated))
58+
->get('/_components/en/component1?'.http_build_query($dehydrated))
5959
->assertSuccessful()
6060
->assertHeaderContains('Content-Type', 'html')
6161
->assertContains('Prop1: '.$entity->id)
6262
->assertContains('Prop2: 2021-03-05 9:23')
6363
->assertContains('Prop3: value3')
6464
->assertContains('Prop4: (none)')
6565

66-
->get('/_components/component1?'.http_build_query($dehydrated), ['headers' => ['Accept' => 'application/vnd.live-component+json']])
66+
->get('/_components/en/component1?'.http_build_query($dehydrated), ['headers' => ['Accept' => 'application/vnd.live-component+json']])
6767
->assertSuccessful()
6868
->assertHeaderEquals('Content-Type', 'application/vnd.live-component+json')
6969
->assertJsonMatches('keys(@)', ['html', 'data'])
@@ -94,26 +94,26 @@ public function testCanExecuteComponentAction(): void
9494

9595
$this->browser()
9696
->throwExceptions()
97-
->get('/_components/component2?'.http_build_query($dehydrated))
97+
->get('/_components/en/component2?'.http_build_query($dehydrated))
9898
->assertSuccessful()
9999
->assertHeaderContains('Content-Type', 'html')
100100
->assertContains('Count: 1')
101101
->use(function (HtmlResponse $response) use (&$token) {
102102
// get a valid token to use for actions
103103
$token = $response->crawler()->filter('div')->first()->attr('data-live-csrf-value');
104104
})
105-
->post('/_components/component2/increase?'.http_build_query($dehydrated), [
105+
->post('/_components/en/component2/increase?'.http_build_query($dehydrated), [
106106
'headers' => ['X-CSRF-TOKEN' => $token],
107107
])
108108
->assertSuccessful()
109109
->assertHeaderContains('Content-Type', 'html')
110110
->assertContains('Count: 2')
111111

112-
->get('/_components/component2?'.http_build_query($dehydrated), ['headers' => ['Accept' => 'application/vnd.live-component+json']])
112+
->get('/_components/en/component2?'.http_build_query($dehydrated), ['headers' => ['Accept' => 'application/vnd.live-component+json']])
113113
->assertSuccessful()
114114
->assertJsonMatches('data.count', 1)
115115
->assertJsonMatches("contains(html, 'Count: 1')", true)
116-
->post('/_components/component2/increase?'.http_build_query($dehydrated), [
116+
->post('/_components/en/component2/increase?'.http_build_query($dehydrated), [
117117
'headers' => [
118118
'Accept' => 'application/vnd.live-component+json',
119119
'X-CSRF-TOKEN' => $token,
@@ -128,22 +128,22 @@ public function testCanExecuteComponentAction(): void
128128
public function testCannotExecuteComponentActionForGetRequest(): void
129129
{
130130
$this->browser()
131-
->get('/_components/component2/increase')
131+
->get('/_components/en/component2/increase')
132132
->assertStatus(405)
133133
;
134134
}
135135

136136
public function testMissingCsrfTokenForComponentActionFails(): void
137137
{
138138
$this->browser()
139-
->post('/_components/component2/increase')
139+
->post('/_components/en/component2/increase')
140140
->assertStatus(400)
141141
;
142142

143143
try {
144144
$this->browser()
145145
->throwExceptions()
146-
->post('/_components/component2/increase')
146+
->post('/_components/en/component2/increase')
147147
;
148148
} catch (BadRequestHttpException $e) {
149149
$this->assertSame('Invalid CSRF token.', $e->getMessage());
@@ -157,7 +157,7 @@ public function testMissingCsrfTokenForComponentActionFails(): void
157157
public function testInvalidCsrfTokenForComponentActionFails(): void
158158
{
159159
$this->browser()
160-
->post('/_components/component2/increase', [
160+
->post('/_components/en/component2/increase', [
161161
'headers' => ['X-CSRF-TOKEN' => 'invalid'],
162162
])
163163
->assertStatus(400)
@@ -166,7 +166,7 @@ public function testInvalidCsrfTokenForComponentActionFails(): void
166166
try {
167167
$this->browser()
168168
->throwExceptions()
169-
->post('/_components/component2/increase', [
169+
->post('/_components/en/component2/increase', [
170170
'headers' => ['X-CSRF-TOKEN' => 'invalid'],
171171
])
172172
;
@@ -196,7 +196,7 @@ public function testBeforeReRenderHookOnlyExecutedDuringAjax(): void
196196
->visit('/render-template/template1')
197197
->assertSuccessful()
198198
->assertSee('BeforeReRenderCalled: No')
199-
->get('/_components/component2?'.http_build_query($dehydrated))
199+
->get('/_components/en/component2?'.http_build_query($dehydrated))
200200
->assertSuccessful()
201201
->assertSee('BeforeReRenderCalled: Yes')
202202
;
@@ -218,19 +218,19 @@ public function testCanRedirectFromComponentAction(): void
218218

219219
$this->browser()
220220
->throwExceptions()
221-
->get('/_components/component2?'.http_build_query($dehydrated))
221+
->get('/_components/en/component2?'.http_build_query($dehydrated))
222222
->assertSuccessful()
223223
->use(function (HtmlResponse $response) use (&$token) {
224224
// get a valid token to use for actions
225225
$token = $response->crawler()->filter('div')->first()->attr('data-live-csrf-value');
226226
})
227227
->interceptRedirects()
228-
->post('/_components/component2/redirect?'.http_build_query($dehydrated), [
228+
->post('/_components/en/component2/redirect?'.http_build_query($dehydrated), [
229229
'headers' => ['X-CSRF-TOKEN' => $token],
230230
])
231231
->assertRedirectedTo('/')
232232

233-
->post('/_components/component2/redirect?'.http_build_query($dehydrated), [
233+
->post('/_components/en/component2/redirect?'.http_build_query($dehydrated), [
234234
'headers' => [
235235
'Accept' => 'application/json',
236236
'X-CSRF-TOKEN' => $token,

src/LiveComponent/tests/Functional/Twig/LiveComponentExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testInitLiveComponent(): void
3434
$data = json_decode($div->attr('data-live-data-value'), true);
3535

3636
$this->assertSame('live', $div->attr('data-controller'));
37-
$this->assertSame('/_components/component2', $div->attr('data-live-url-value'));
37+
$this->assertSame('/_components/en/component2', $div->attr('data-live-url-value'));
3838
$this->assertNotNull($div->attr('data-live-csrf-value'));
3939
$this->assertCount(2, $data);
4040
$this->assertSame(1, $data['count']);

0 commit comments

Comments
 (0)