Skip to content

Commit

Permalink
Added test for MorphMap usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwin-wildsea committed Nov 19, 2024
1 parent 53517a7 commit 650479e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/src/LanguageSwitcherTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Str;
use TomatoPHP\FilamentLanguageSwitcher\Tests\Models\User;

Expand Down Expand Up @@ -60,3 +61,21 @@

expect($currentLang)->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();
});

0 comments on commit 650479e

Please sign in to comment.