13
13
14
14
use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
15
15
use Symfony \Component \DomCrawler \Crawler ;
16
+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
16
17
use Symfony \UX \LiveComponent \Tests \LiveComponentTestHelper ;
17
18
use Zenstruck \Browser \KernelBrowser ;
18
19
use Zenstruck \Browser \Test \HasBrowser ;
@@ -160,6 +161,7 @@ public function testException(): void
160
161
$ this ->browser ()
161
162
->get ('/_components/with_actions ' , ['query ' => ['props ' => json_encode ($ dehydrated ->getProps ())]])
162
163
->assertSuccessful ()
164
+ ->expectException (\RuntimeException::class, 'Exception message ' )
163
165
->use (function (Crawler $ crawler , KernelBrowser $ browser ) {
164
166
$ rootElement = $ crawler ->filter ('ul ' )->first ();
165
167
$ liveProps = json_decode ($ rootElement ->attr ('data-live-props-value ' ), true );
@@ -178,8 +180,6 @@ public function testException(): void
178
180
'headers ' => ['X-CSRF-TOKEN ' => $ crawler ->filter ('ul ' )->first ()->attr ('data-live-csrf-value ' )],
179
181
]);
180
182
})
181
- ->assertStatus (500 )
182
- ->assertContains ('Exception message ' )
183
183
;
184
184
}
185
185
@@ -190,6 +190,7 @@ public function testCannotBatchWithNonLiveAction(): void
190
190
$ this ->browser ()
191
191
->get ('/_components/with_actions ' , ['query ' => ['props ' => json_encode ($ dehydrated ->getProps ())]])
192
192
->assertSuccessful ()
193
+ ->expectException (NotFoundHttpException::class, 'The action "nonLive" either doesn \'t exist or is not allowed ' )
193
194
->use (function (Crawler $ crawler , KernelBrowser $ browser ) {
194
195
$ rootElement = $ crawler ->filter ('ul ' )->first ();
195
196
$ liveProps = json_decode ($ rootElement ->attr ('data-live-props-value ' ), true );
@@ -208,8 +209,6 @@ public function testCannotBatchWithNonLiveAction(): void
208
209
'headers ' => ['X-CSRF-TOKEN ' => $ crawler ->filter ('ul ' )->first ()->attr ('data-live-csrf-value ' )],
209
210
]);
210
211
})
211
- ->assertStatus (404 )
212
- ->assertContains ('The action \"nonLive\" either doesn \'t exist or is not allowed ' )
213
212
;
214
213
}
215
214
}
0 commit comments