parsaaghayi-backend/tests/Unit/ModelsTest.php

41 lines
1.1 KiB
PHP

<?php
namespace Tests\Unit;
use App\Models\Website\AboutMe;
use App\Models\Website\Skill;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ModelsTest extends TestCase
{
use RefreshDatabase;
public function test_about_me_can_set_and_get_translations()
{
$aboutMe = AboutMe::factory()->create();
$aboutMe->setTranslation('title', 'en', 'Hello');
$aboutMe->setTranslation('title', 'fa', 'سلام');
$aboutMe->save();
$this->assertEquals('Hello', $aboutMe->getTranslation('title', 'en'));
$this->assertEquals('سلام', $aboutMe->getTranslation('title', 'fa'));
}
public function test_about_me_has_skills_relation()
{
$aboutMe = AboutMe::factory()->create();
Skill::factory()->count(2)->create(['about_me_id' => $aboutMe->id]);
$this->assertCount(2, $aboutMe->skills);
}
public function test_about_me_fillable_fields()
{
$aboutMe = AboutMe::factory()->create(['image' => 'photo.jpg']);
$this->assertEquals('photo.jpg', $aboutMe->image);
}
}