diff --git a/tests/src/LanguageSwitcherTest.php b/tests/src/LanguageSwitcherTest.php index 44efd0d..f74e5af 100644 --- a/tests/src/LanguageSwitcherTest.php +++ b/tests/src/LanguageSwitcherTest.php @@ -1,5 +1,6 @@ toBeTrue(); }); + +it('can switch language while using morphMap', function () { + // Register Relation MorphMap + Relation::morphMap(['user' => get_class(auth()->user())]); + + $response = get(route('languages.switcher', [ + 'model' => get_class(auth()->user()), + 'model_id' => auth()->user()->id, + 'lang' => 'ar', + ])); + + // Ensure the response status is OK (200) + $response->assertStatus(302); + + $currentLang = auth('web')->user()->lang == 'ar'; + + expect($currentLang)->toBeTrue(); +});