completed story 1.1 with QA tests and fixes

This commit is contained in:
Naser Mansour
2025-12-26 13:46:39 +02:00
parent 028ce573b9
commit 84d9c2f66a
57 changed files with 2193 additions and 85 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
use App\Models\Post;
test('post getTitle returns title in specified locale', function () {
$post = Post::factory()->create([
'title' => ['ar' => 'عنوان عربي', 'en' => 'English Title'],
]);
expect($post->getTitle('ar'))->toBe('عنوان عربي')
->and($post->getTitle('en'))->toBe('English Title');
});
test('post getTitle falls back to Arabic when locale missing', function () {
$post = Post::factory()->create([
'title' => ['ar' => 'عنوان عربي'],
]);
expect($post->getTitle('en'))->toBe('عنوان عربي');
});
test('post getTitle uses current locale by default', function () {
$post = Post::factory()->create([
'title' => ['ar' => 'عنوان عربي', 'en' => 'English Title'],
]);
app()->setLocale('en');
expect($post->getTitle())->toBe('English Title');
app()->setLocale('ar');
expect($post->getTitle())->toBe('عنوان عربي');
});
test('post getBody returns body in specified locale', function () {
$post = Post::factory()->create([
'body' => ['ar' => 'محتوى عربي', 'en' => 'English Content'],
]);
expect($post->getBody('ar'))->toBe('محتوى عربي')
->and($post->getBody('en'))->toBe('English Content');
});
test('post getBody falls back to Arabic when locale missing', function () {
$post = Post::factory()->create([
'body' => ['ar' => 'محتوى عربي'],
]);
expect($post->getBody('en'))->toBe('محتوى عربي');
});